package com.szosen.util;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Handler;
import android.text.TextUtils;

import com.szosen.database.AccessoryExamination;
import com.szosen.database.DBService;
import com.szosen.database.Examination;
import com.szosen.database.HealthAssessment;
import com.szosen.database.HealthRecord;
import com.szosen.database.InhospitalSituation;
import com.szosen.database.LifestySituation;
import com.szosen.database.MedicineDesc;
import com.szosen.database.MedicineSituation;
import com.szosen.database.NonimmuneInoculation;
import com.szosen.database.Visit_info;
import com.szosen.database.Visit_info2;
import com.szosen.database.base_info;
import com.szosen.database.jwsjb;
import com.szosen.database.jwsss;
import com.szosen.database.jwssx;
import com.szosen.database.jwsws;
import com.szosen.jkzj.R;
import com.szosen.jkzj.activity.BaseActivity;
import com.szosen.json.Archive;
import com.szosen.json.ArchiveDetail;
import com.szosen.json.GetArchiveDetail;
import com.szosen.json.OldAssessment;
import com.szosen.json.PastHistorylist;
import com.szosen.xml.XmlTool;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class JktjBitmapUtil {
    private static final Paint textPaint = new Paint();
    private static final Paint smallTextPaint = new Paint();
    private static final int textColor = Color.BLACK;
    private static int textSize = 27;
    private static int smallTextSize = 18;

    static {
        textPaint.setStrokeWidth(3);
        textPaint.setDither(true);
        textPaint.setStyle(Paint.Style.FILL);
        textPaint.setTextSize(textSize);
        textPaint.setColor(textColor);

        smallTextPaint.setStrokeWidth(3);
        smallTextPaint.setDither(true);
        smallTextPaint.setStyle(Paint.Style.FILL);
        smallTextPaint.setTextSize(smallTextSize);
        smallTextPaint.setColor(textColor);
    }


    /***
     * 按照日期导出体检日期。
     * @param context
     * @param handler
     * @param printDate
     * @param printAll 是否需要打印全部
     */
    public static void exportJKTJTable(final Context context, final Handler handler, final String printDate, boolean printAll) {
        new BackGroundThread(new BackGroundThread.BackGroundTask() {
            @Override
            public void process() {

                HealthRecord queryHR = new HealthRecord();
                List<Object> hrs = (List<Object>) DBService.getAll(queryHR);
                //循环健康档案的列表
                if (hrs != null && hrs.size() > 0) {
                    for (int i = 0; i < hrs.size(); i++) {
                        HealthRecord hr = (HealthRecord) hrs.get(i);
                        String idcard = hr.getIdCard();
                        base_info base = new base_info();
                        base.setIdCard(idcard);
                        //获取某人的身份证号，然后查询该人的体检表
                        List<base_info> lists = (List<base_info>) DBService.queryByIdCard(base);
                        for (int j = 0; j < lists.size(); j++) {
                            base_info bi = lists.get(j);
                            String date = bi.getCheckDate();
                            String time = bi.getTime();
                            //获取当前的日期的格式2017-07-07，比对checkDate体检日期，然后符合需要打印的日期则打印出来。
                            if (date.contains(printDate)) {
                                createOnejktjTable(context, time, date, hr.getPersonName(), false);
                            } else if (TextUtils.isEmpty(printDate)) {
                                createOnejktjTable(context, time, date, hr.getPersonName(), true);
                            }
                        }
                    }
                }
            }
        }).start();
        ;
    }

    /***
     * 在sd卡中生成一份健康体检表，根据打印日期，个人姓名、查询的time主键
     * @param context
     * @param time
     * @param checkDate 体检日期，用于图片的命名。
     * @param personName
     */
    public static void createOnejktjTable(Context context, String time, String checkDate, String personName, boolean printAll) {
        base_info b = new base_info();
        b.setTime(time);
        Examination e = new Examination();
        e.setTime(time);
        NonimmuneInoculation n = new NonimmuneInoculation();
        n.setTime(time);
        AccessoryExamination a = new AccessoryExamination();
        a.setTime(time);
        HealthAssessment h = new HealthAssessment();
        h.setTime(time);
        LifestySituation l = new LifestySituation();
        l.setTime(time);
        MedicineSituation m = new MedicineSituation();
        m.setTime(time);
        InhospitalSituation i = new InhospitalSituation();
        i.setTime(time);
        /** 基本情况 */
        base_info mjktj_baseInfo = null;
        /** 查体 */
        Examination mjktj_Examination = null;
        /** 辅助检查 */
        AccessoryExamination mjktj_AccessoryExamination = null;
        /** 健康评价表 */
        HealthAssessment mjktj_HealthAssessment = null;
        /** 生活方式 */
        LifestySituation mjktj_LifestySituation = null;
        /** 住院用药情况 */
        MedicineSituation mjktj_MedicineSituation = null;
        /** 住院治疗情况 */
        InhospitalSituation mjktj_InhospitalSituation = null;
        /** 非免疫接种 */
        NonimmuneInoculation mjktj_NonimmuneInoculation = null;
        List<base_info> bs = (List<base_info>) DBService.queryByKey(b);
        if (bs.size() > 0) {
            mjktj_baseInfo = bs.get(0);
        }
        /** 查体 */
        List<Examination> es = (List<Examination>) DBService.queryByKey(e);
        if (es.size() > 0) {
            mjktj_Examination = es.get(0);
        }
        List<NonimmuneInoculation> ns = (List<NonimmuneInoculation>) DBService
                .queryByKey(n);
        if (ns.size() > 0) {
            mjktj_NonimmuneInoculation = ns.get(0);
        }
        List<AccessoryExamination> as = (List<AccessoryExamination>) DBService
                .queryByKey(a);
        if (as.size() > 0) {
            mjktj_AccessoryExamination = as.get(0);
        }
        List<HealthAssessment> hs = (List<HealthAssessment>) DBService
                .queryByKey(h);
        if (hs.size() > 0) {
            mjktj_HealthAssessment = hs.get(0);
        }
        List<LifestySituation> ls = (List<LifestySituation>) DBService
                .queryByKey(l);
        if (ls.size() > 0) {
            mjktj_LifestySituation = ls.get(0);
        }
        List<MedicineSituation> ms = (List<MedicineSituation>) DBService
                .queryByKey(m);
        if (ms.size() > 0) {
            mjktj_MedicineSituation = ms.get(0);
        }
        List<InhospitalSituation> is = (List<InhospitalSituation>) DBService
                .queryByKey(i);
        if (is.size() > 0) {
            mjktj_InhospitalSituation = is.get(0);
        }
        System.gc();
        // 体检表1的画布，用来画好字。然后保存。
        Bitmap bitmap1 = getBitmapByResId(context, R.raw.tijianbiao1);
        Bitmap tijianbiao1 = Bitmap.createBitmap(bitmap1.getWidth(),
                bitmap1.getHeight(), Bitmap.Config.RGB_565);
        Canvas canvas1 = new Canvas(tijianbiao1);
        canvas1.drawBitmap(bitmap1, 0, 0, null);
        bitmap1.recycle();
        // 体检表2
        Bitmap bitmap2 = getBitmapByResId(context, R.raw.tijianbiao2);
        Bitmap tijianbiao2 = Bitmap.createBitmap(bitmap2.getWidth(),
                bitmap2.getHeight(), Bitmap.Config.RGB_565);
        Canvas canvas2 = new Canvas(tijianbiao2);
        canvas2.drawBitmap(bitmap2, 0, 0, null);
        bitmap2.recycle();
        // 体检表3
        Bitmap bitmap3 = getBitmapByResId(context, R.raw.tijianbiao3);
        Bitmap tijianbiao3 = Bitmap.createBitmap(bitmap3.getWidth(),
                bitmap3.getHeight(), Bitmap.Config.RGB_565);
        Canvas canvas3 = new Canvas(tijianbiao3);
        canvas3.drawBitmap(bitmap3, 0, 0, null);
        bitmap3.recycle();
        System.gc();
        // 体检表3
        Bitmap bitmap4 = getBitmapByResId(context, R.raw.tijianbiao4);
        Bitmap tijianbiao4 = Bitmap.createBitmap(bitmap4.getWidth(),
                bitmap4.getHeight(), Bitmap.Config.RGB_565);
        Canvas canvas4 = new Canvas(tijianbiao4);
        canvas4.drawBitmap(bitmap4, 0, 0, null);
        bitmap4.recycle();
        drawBaseInfo(canvas1, mjktj_baseInfo, mjktj_LifestySituation);
        drawBitmap2(canvas2, mjktj_AccessoryExamination, mjktj_Examination);
        drawBitmap3(canvas3, mjktj_baseInfo, mjktj_AccessoryExamination, mjktj_Examination,
                mjktj_HealthAssessment);
        drawBitmap4(canvas4, mjktj_baseInfo, mjktj_HealthAssessment);
        String fileDate = printAll ? "全部" : checkDate;
        String savePath = FileSaveUtil.getSDCardPath() + File.separator + "体检表导出目录" + File.separator + fileDate + File.separator + personName;
        FileSaveUtil.saveBitmap(tijianbiao1, savePath,
                checkDate + "_tijianbiao1.png");
        FileSaveUtil.saveBitmap(tijianbiao2, savePath,
                checkDate + "_tijianbiao2.png");
        FileSaveUtil.saveBitmap(tijianbiao3, savePath,
                checkDate + "_tijianbiao3.png");
        FileSaveUtil.saveBitmap(tijianbiao4, savePath,
                checkDate + "_tijianbiao4.png");
        tijianbiao1.recycle();
        tijianbiao2.recycle();
        tijianbiao3.recycle();
        tijianbiao4.recycle();
//        File path = new File(FileSaveUtil.getSDCardPath() + File.separator + personName);
//        if (!path.exists()) {
//            path.mkdirs();
//        }
//        File f1 = new File(path, "tijianbiao1.png");
//        File f2 = new File(path, "tijianbiao2.png");
//        File f3 = new File(path, "tijianbiao3.png");
//        File f4 = new File(path, "tijianbiao4.png");
        System.gc();
    }

    public static void createjktjBitmaps(Context context, base_info baseInfo,
                                         Examination examination, AccessoryExamination accessoryExamination,
                                         HealthAssessment healthAssessment,
                                         LifestySituation lifestySituation,
                                         MedicineSituation medicineSituation,
                                         InhospitalSituation inhospitalSituation,
                                         NonimmuneInoculation nonimmuneInoculation, int printType) {
        System.gc();
        //printType=0 全部打印
        if (printType == 0) {
            // 体检表1的画布，用来画好字。然后保存。
            Bitmap bitmap1 = getBitmapByResId(context, R.raw.tijianbiao1);
            Bitmap tijianbiao1 = Bitmap.createBitmap(bitmap1.getWidth(),
                    bitmap1.getHeight(), Bitmap.Config.ARGB_4444);
            Canvas canvas1 = new Canvas(tijianbiao1);
            canvas1.drawBitmap(bitmap1, 0, 0, null);
            bitmap1.recycle();
            // 体检表2
            Bitmap bitmap2 = getBitmapByResId(context, R.raw.tijianbiao2);
            Bitmap tijianbiao2 = Bitmap.createBitmap(bitmap2.getWidth(),
                    bitmap2.getHeight(), Bitmap.Config.ARGB_4444);
            Canvas canvas2 = new Canvas(tijianbiao2);
            canvas2.drawBitmap(bitmap2, 0, 0, null);
            bitmap2.recycle();
            // 体检表3
            Bitmap bitmap3 = getBitmapByResId(context, R.raw.tijianbiao3);
            Bitmap tijianbiao3 = Bitmap.createBitmap(bitmap3.getWidth(),
                    bitmap3.getHeight(), Bitmap.Config.ARGB_4444);
            Canvas canvas3 = new Canvas(tijianbiao3);
            canvas3.drawBitmap(bitmap3, 0, 0, null);
            bitmap3.recycle();
            // 体检表3
            Bitmap bitmap4 = getBitmapByResId(context, R.raw.tijianbiao4);
            Bitmap tijianbiao4 = Bitmap.createBitmap(bitmap4.getWidth(),
                    bitmap4.getHeight(), Bitmap.Config.ARGB_4444);
            Canvas canvas4 = new Canvas(tijianbiao4);
            canvas4.drawBitmap(bitmap4, 0, 0, null);
            bitmap4.recycle();
            drawBaseInfo(canvas1, baseInfo, lifestySituation);
            drawBitmap2(canvas2, accessoryExamination, examination);
            drawBitmap3(canvas3, baseInfo, accessoryExamination, examination,
                    healthAssessment);
            drawBitmap4(canvas4, baseInfo, healthAssessment);
            String name = BaseActivity.getName();
            String basePath = FileSaveUtil.getPrintPath_JKTJ() + File.separator + name;
            FileSaveUtil.saveBitmap(tijianbiao1, basePath,
                    "tijianbiao1.png");
            FileSaveUtil.saveBitmap(tijianbiao2, basePath,
                    "tijianbiao2.png");
            FileSaveUtil.saveBitmap(tijianbiao3, basePath,
                    "tijianbiao3.png");
            FileSaveUtil.saveBitmap(tijianbiao4, basePath,
                    "tijianbiao4.png");
            tijianbiao1.recycle();
            tijianbiao2.recycle();
            tijianbiao3.recycle();
            tijianbiao4.recycle();
            Intent intent = new Intent();
            intent.setAction("android.intent.action.SEND_MULTIPLE");
            intent.setType("image/*");
            ArrayList<Uri> imageUris = new ArrayList<Uri>();
            File f1 = new File(basePath, "tijianbiao1.png");
            File f2 = new File(basePath, "tijianbiao2.png");
            File f3 = new File(basePath, "tijianbiao3.png");
            File f4 = new File(basePath, "tijianbiao4.png");
            imageUris.add(Uri.fromFile(f1));
            imageUris.add(Uri.fromFile(f2));
            imageUris.add(Uri.fromFile(f3));
            imageUris.add(Uri.fromFile(f4));
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
            context.startActivity(intent);
        } else if (printType == 1) {
            // 体检表1的画布，用来画好字。然后保存。
            Bitmap bitmap1 = getBitmapByResId(context, R.raw.tijianbiao1);
            Bitmap tijianbiao1 = Bitmap.createBitmap(bitmap1.getWidth(),
                    bitmap1.getHeight(), Bitmap.Config.ARGB_4444);
            Canvas canvas1 = new Canvas(tijianbiao1);
            canvas1.drawBitmap(bitmap1, 0, 0, null);
            bitmap1.recycle();
            // 体检表3
            Bitmap bitmap3 = getBitmapByResId(context, R.raw.tijianbiao3);
            Bitmap tijianbiao3 = Bitmap.createBitmap(bitmap3.getWidth(),
                    bitmap3.getHeight(), Bitmap.Config.ARGB_4444);
            Canvas canvas3 = new Canvas(tijianbiao3);
            canvas3.drawBitmap(bitmap3, 0, 0, null);
            bitmap3.recycle();
            drawBaseInfo(canvas1, baseInfo, lifestySituation);
            drawBitmap3(canvas3, baseInfo, accessoryExamination, examination,
                    healthAssessment);
            FileSaveUtil.saveBitmap(tijianbiao1, FileSaveUtil.getSDCardPath(),
                    "tijianbiao1.png");
            FileSaveUtil.saveBitmap(tijianbiao3, FileSaveUtil.getSDCardPath(),
                    "tijianbiao3.png");
            tijianbiao1.recycle();
            tijianbiao3.recycle();
            Intent intent = new Intent();
            intent.setAction("android.intent.action.SEND_MULTIPLE");
            intent.setType("image/*");
            ArrayList<Uri> imageUris = new ArrayList<Uri>();
            File f1 = new File(FileSaveUtil.getSDCardPath(), "tijianbiao1.png");
            File f3 = new File(FileSaveUtil.getSDCardPath(), "tijianbiao3.png");
            imageUris.add(Uri.fromFile(f1));
            imageUris.add(Uri.fromFile(f3));
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
            context.startActivity(intent);
        } else if (printType == 2) {
            // 体检表2
            Bitmap bitmap2 = getBitmapByResId(context, R.raw.tijianbiao2);
            Bitmap tijianbiao2 = Bitmap.createBitmap(bitmap2.getWidth(),
                    bitmap2.getHeight(), Bitmap.Config.ARGB_4444);
            Canvas canvas2 = new Canvas(tijianbiao2);
            canvas2.drawBitmap(bitmap2, 0, 0, null);
            bitmap2.recycle();
            // 体检表3
            Bitmap bitmap4 = getBitmapByResId(context, R.raw.tijianbiao4);
            Bitmap tijianbiao4 = Bitmap.createBitmap(bitmap4.getWidth(),
                    bitmap4.getHeight(), Bitmap.Config.ARGB_4444);
            Canvas canvas4 = new Canvas(tijianbiao4);
            canvas4.drawBitmap(bitmap4, 0, 0, null);
            bitmap4.recycle();
            drawBitmap2(canvas2, accessoryExamination, examination);
            drawBitmap4(canvas4, baseInfo, healthAssessment);
            FileSaveUtil.saveBitmap(tijianbiao2, FileSaveUtil.getSDCardPath(),
                    "tijianbiao2.png");
            FileSaveUtil.saveBitmap(tijianbiao4, FileSaveUtil.getSDCardPath(),
                    "tijianbiao4.png");
            tijianbiao2.recycle();
            tijianbiao4.recycle();
            Intent intent = new Intent();
            intent.setAction("android.intent.action.SEND_MULTIPLE");
            intent.setType("image/*");
            ArrayList<Uri> imageUris = new ArrayList<Uri>();
            File f2 = new File(FileSaveUtil.getSDCardPath(), "tijianbiao2.png");
            File f4 = new File(FileSaveUtil.getSDCardPath(), "tijianbiao4.png");
            imageUris.add(Uri.fromFile(f2));
            imageUris.add(Uri.fromFile(f4));
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
            context.startActivity(intent);
        }
    }

    public static Bitmap getBitmapByResId(Context context, int resId) {
        Bitmap bitmap1 = BitmapFactory.decodeResource(context.getResources(),
                resId);
        return bitmap1;
    }

    public static void drawBaseInfo(Canvas canvas, base_info baseInfo,
                                    LifestySituation lifestySituation) {
        base_info dataBean = baseInfo;
        String name = BaseActivity.getName();
        textPaint.setTextSize(32);
        canvas.drawText(name, 400, 315, textPaint);
        textPaint.setTextSize(textSize);
        String checkDate = dataBean.getCheckDate();
        if (checkDate.length() >= 10) {
            String year = checkDate.substring(0, 4);
            String month = checkDate.substring(5, 7);
            String day = checkDate.substring(8, 10);
            canvas.drawText(year, 430, 380, textPaint);
            canvas.drawText(month, 580, 380, textPaint);
            canvas.drawText(day, 680, 380, textPaint);
        }
        canvas.drawText(dataBean.getDoctorName(), 1200, 380, textPaint);
        // 症状
        String grzz = dataBean.getSymptom();
        String[] grzzs = grzz.split(",");
        for (int i = 0; i < grzzs.length; i++) {
            try {
                if (TextUtils.isEmpty(grzzs[i])) {
                    continue;
                }
                if (grzzs[i].length() >= 2) {
                    grzzs[i] = grzzs[i].replace("0", "");
                    canvas.drawText(grzzs[i], 1130 + 43 * i, 614,
                            smallTextPaint);
                }
                // zhengzhuang24_other.setText();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        canvas.drawText(dataBean.getSymptomOt(), 1160, 560, textPaint);
        canvas.drawText(dataBean.getTemperature(), 600, 665, textPaint);
        canvas.drawText(dataBean.getBreathe(), 600, 735, textPaint);// 呼吸频率
        canvas.drawText(dataBean.getPulse(), 1170, 665, textPaint);// 脉率
        canvas.drawText(dataBean.getConstriction(), 1270, 715, textPaint);// 收缩压
        canvas.drawText(dataBean.getDiastolic(), 1400, 715, textPaint);// 舒张压
        canvas.drawText(dataBean.getConstriction_L(), 1270, 760, textPaint);// 收缩压右边
        canvas.drawText(dataBean.getDiastolic_L(), 1400, 760, textPaint);// 舒张压右边
        canvas.drawText(dataBean.getHeight(), 600, 805, textPaint);// 身高
        canvas.drawText(dataBean.getWeight(), 1170, 805, textPaint);// 体重
        canvas.drawText(dataBean.getWaistline(), 600, 853, textPaint);// 腰围
        canvas.drawText(dataBean.getBmi(), 1170, 853, textPaint);// bmi
        canvas.drawText(dataBean.getSelfCare(), 1548, 915, smallTextPaint);// bmi
        canvas.drawText(dataBean.getHealthStatus(), 1548, 1008, smallTextPaint);// 健康情况
        canvas.drawText(dataBean.getCognitive(), 1548, 1102, smallTextPaint);// 老人认知功能
        canvas.drawText(dataBean.getCognitiveZf(), 1120, 1120, textPaint);// 老人认知功能评分
        canvas.drawText(dataBean.getEmotion(), 1548, 1173, smallTextPaint);// 老人情感状态
        canvas.drawText(dataBean.getEmotionZf(), 1120, 1220, textPaint);// 老人情感状态总分
        canvas.drawText(lifestySituation.getPhysicalExerciseFrequency(), 1548,
                1260, smallTextPaint);// 体育频率
        canvas.drawText(lifestySituation.getEveryPhysicalExerciseTime(), 855,
                1310, textPaint);//
        canvas.drawText(lifestySituation.getInsistexercisetime(), 1325, 1310,
                textPaint);//
        canvas.drawText(lifestySituation.getExerciseStyle(), 800, 1361,
                textPaint);//
        String ysxg = lifestySituation.getDietaryHabit();
        if (!TextUtils.isEmpty(ysxg)) {
            String[] ysxg01 = ysxg.split(",");
            for (int i = 0; i < ysxg01.length; i++) {
                canvas.drawText(ysxg01[i], 1460 + 43 * i, 1402, smallTextPaint);//
            }
        }
        canvas.drawText(lifestySituation.getWehtherSmoke(), 1548, 1450,
                smallTextPaint);// 吸烟状况
        canvas.drawText(lifestySituation.getSmokes(), 845, 1503, textPaint);//
        canvas.drawText(lifestySituation.getBeginSmokeTime(), 845, 1554,
                textPaint);// 开始吸烟年龄
        canvas.drawText(lifestySituation.getStopSmokeTime(), 1364, 1554,
                textPaint);// 戒烟年龄
        canvas.drawText(lifestySituation.getDrinkingFrequency(), 1548, 1602,
                smallTextPaint);// 饮酒频率
        canvas.drawText(lifestySituation.getAlcoholConsumption(), 845, 1652,
                textPaint);// 日饮酒量
        canvas.drawText(lifestySituation.getWhetherDrink(), 1548, 1703,
                smallTextPaint);// 是不是解救了。
        canvas.drawText(lifestySituation.getStopDrinkingTime(), 1207, 1703,
                textPaint);// 戒酒年龄。
        canvas.drawText(lifestySituation.getBeginToDrinkTime(), 845, 1768,
                textPaint);// 开始饮酒年龄
        canvas.drawText(lifestySituation.getIsDrink(), 1548, 1757,
                smallTextPaint);// 是否醉酒
        String yjzl = lifestySituation.getMainDrinkingVvarieties();
        if (!TextUtils.isEmpty(yjzl)) {
            String[] yjzl01 = yjzl.split(",");
            for (int i = 0; i < yjzl01.length; i++) {
                if (yjzl01[i].equals("9")) {
                    yjzl01[i] = "5";
                }
                canvas.drawText(yjzl01[i], 1414 + 45 * i, 1811, smallTextPaint);// 饮酒种类
            }
        }
        canvas.drawText(lifestySituation.getDrinkOther(), 1246, 1811, textPaint);//
        canvas.drawText(lifestySituation.getJobs(), 755, 1853, textPaint);// 工种
        canvas.drawText(lifestySituation.getWorkTime(), 967, 1853, textPaint);// 工种时间
        canvas.drawText(lifestySituation.getDust(), 803, 1891, textPaint);// 粉尘
        canvas.drawText(lifestySituation.getDustPro(), 1548, 1862,
                smallTextPaint);// 粉尘1,2
        canvas.drawText(lifestySituation.getDustProDesc(), 1224, 1895,
                textPaint);// 粉尘描述
        canvas.drawText(lifestySituation.getRay(), 803, 1931, textPaint);// 放射
        canvas.drawText(lifestySituation.getRayPro(), 1548, 1906,
                smallTextPaint);// 放射1 2
        canvas.drawText(lifestySituation.getRayProDesc(), 1224, 1932, textPaint);// 放射描述
        canvas.drawText(lifestySituation.getPhysicalFactor(), 803, 1969,
                textPaint);// 物理
        canvas.drawText(lifestySituation.getPhysicalFactorPro() == null ? ""
                        : lifestySituation.getPhysicalFactorPro(), 1548, 1952,
                smallTextPaint);// 物理1 2
        canvas.drawText(lifestySituation.getPhysicalFactorProDesc(), 1224,
                1972, textPaint);// 物理描述
        canvas.drawText(lifestySituation.getChemicals(), 803, 2009, textPaint);// 化学
        canvas.drawText(lifestySituation.getChemicalsPro(), 1548, 1996,
                smallTextPaint);// 化学1 2
        canvas.drawText(lifestySituation.getChemicalsProDesc(), 1224, 2010,
                textPaint);// 化学描述
        canvas.drawText(lifestySituation.getOther(), 803, 2046, textPaint);// 其他
        canvas.drawText(lifestySituation.getOtherPro() == null ? ""
                : lifestySituation.getOtherPro(), 1548, 2043, smallTextPaint);// 其他1
        canvas.drawText(lifestySituation.getOtherProDesc(), 1224, 2047,
                textPaint);// 其他描述
    }

    /***
     * 辅助检查
     *
     * @param canvas
     * @param accessoryExamination
     */
    public static void drawBitmap2(Canvas canvas,
                                   AccessoryExamination accessoryExamination, Examination examination) {
        AccessoryExamination uploadBean = accessoryExamination;
        // 口唇
        canvas.drawText(uploadBean.getLip(), 1548, 205, smallTextPaint);// 其
        canvas.drawText(uploadBean.getPharyngeal(), 1548, 250, smallTextPaint);// 齿列
        canvas.drawText(uploadBean.getDenture(), 1548, 296, smallTextPaint);// 咽喉部
        canvas.drawText(uploadBean.getLeftEye(), 592, 351, textPaint);// 左眼
        canvas.drawText(uploadBean.getRightEye(), 760, 351, textPaint);// 右眼
        canvas.drawText(uploadBean.getRecLeftEye(), 1110, 351, textPaint);// 矫正左眼
        canvas.drawText(uploadBean.getRecRightEye(), 1315, 351, textPaint);// 矫正右眼
        canvas.drawText(uploadBean.getHearing(), 1548, 410, smallTextPaint);// 听力
        canvas.drawText(uploadBean.getMotion(), 1548, 466, smallTextPaint);// 运动能力
        canvas.drawText(examination.getFundus(), 1548, 521, smallTextPaint);// 眼底
        canvas.drawText(examination.getFundusDesc(), 724, 523, textPaint);// 眼底描述
        canvas.drawText(examination.getSkin(), 1548, 587, smallTextPaint);// 皮肤
        canvas.drawText(examination.getSkinDesc(), 1294, 589, textPaint);//
        canvas.drawText(examination.getSclera(), 1548, 657, smallTextPaint);// 巩膜
        canvas.drawText(examination.getScleraDesc(), 929, 657, textPaint);// 巩膜
        canvas.drawText(examination.getLymphnodes(), 1548, 718, smallTextPaint);// 淋巴结
        canvas.drawText(examination.getLymphnodesDesc(), 1047, 721, textPaint);// 淋巴结描述
        canvas.drawText(examination.getBarrelChest(), 1548, 780, smallTextPaint);// 桶状胸
        canvas.drawText(examination.getBreathSound(), 1548, 837, smallTextPaint);// 呼吸音
        canvas.drawText(examination.getBreathSoundDesc(), 841, 840, textPaint);// 呼吸音描述
        canvas.drawText(examination.getBreathSound(), 1548, 895, smallTextPaint);// 啰音
        canvas.drawText(examination.getBreathSoundDesc(), 1117, 899, textPaint);// 啰音描述
        canvas.drawText(examination.getRhythm(), 1548, 951, smallTextPaint);// 心率齐不齐
        canvas.drawText(examination.getHeartRate(), 608, 954, textPaint);// 心率次数
        canvas.drawText(examination.getHeartMurmur(), 1548, 995, smallTextPaint);// 杂音
        canvas.drawText(examination.getHeartMurmurDesc(), 849, 998, textPaint);// 杂音描述
        canvas.drawText(examination.getHeartMurmur(), 1548, 1047,
                smallTextPaint);// 压痛
        canvas.drawText(examination.getHeartMurmurDesc(), 751, 1045, textPaint);// 压痛描述
        canvas.drawText(examination.getAdbominAlmass(), 1548, 1092,
                smallTextPaint);// 包块
        canvas.drawText(examination.getAdbominAlmassDesc(), 751, 1092,
                textPaint);// 包块描述
        canvas.drawText(examination.getLiverBig(), 1548, 1138, smallTextPaint);// 肝大
        canvas.drawText(examination.getLiverBigDesc(), 751, 1136, textPaint);// 肝大描述
        canvas.drawText(examination.getSplenomegaly(), 1548, 1184,
                smallTextPaint);// 脾大
        canvas.drawText(examination.getSplenomegalyDesc(), 751, 1183, textPaint);// 脾大描述
        canvas.drawText(examination.getDullness(), 1548, 1229, smallTextPaint);// 移动性浊音
        canvas.drawText(examination.getDullnessDesc(), 848, 1228, textPaint);// 移动性浊音描述
        canvas.drawText(examination.getEdema(), 1548, 1274, smallTextPaint);// 下肢水肿
        canvas.drawText(examination.getFootPulse(), 1548, 1323, smallTextPaint);// 足背动脉搏动
        String gmzz = examination.getDre();
        String[] gmzzs = gmzz.split(",");
        for (int i = 0; i < gmzzs.length; i++) {
            if (gmzzs[i].equals("9")) {
                gmzzs[i] = "5";
            }
            canvas.drawText(gmzzs[i], 1548, 1374, smallTextPaint);// 肛门指诊
        }
        canvas.drawText(examination.getDreDesc(), 1296, 1374, textPaint);// 肛门指诊描述

        String rx = examination.getBreast();
        String[] rxs = rx.split(",");
        for (int i = 0; i < rxs.length; i++) {
            if (rxs[i].equals("9")) {
                rxs[i] = "5";
            }
            canvas.drawText(rxs[i], 1413 + i * 45, 1446, smallTextPaint);// ruxian
        }
        canvas.drawText(examination.getBreastDesc(), 1218, 1449, textPaint);// 乳腺描述
        canvas.drawText(examination.getVulva(), 1548, 1508, smallTextPaint);// 外阴
        canvas.drawText(examination.getVulvaDesc(), 806, 1508, textPaint);// 外阴描述
        canvas.drawText(examination.getVulva(), 1548, 1572, smallTextPaint);// 阴道
        canvas.drawText(examination.getVulvaDesc(), 806, 1575, textPaint);// 阴道描述
        canvas.drawText(examination.getCervix(), 1548, 1636, smallTextPaint);// 宫颈
        canvas.drawText(examination.getCervixDesc(), 806, 1640, textPaint);// 宫颈描述
        canvas.drawText(examination.getPalace(), 1548, 1699, smallTextPaint);// 宫体
        canvas.drawText(examination.getPalaceDesc(), 806, 1704, textPaint);// 宫体描述
        canvas.drawText(examination.getAttachment(), 1548, 1763, smallTextPaint);// 附件
        canvas.drawText(examination.getAttachmentDesc(), 806, 1767, textPaint);// 附件描述
        canvas.drawText(examination.getTjother(), 524, 1845, textPaint);// 其他
        canvas.drawText(accessoryExamination.getHgb(), 639, 1897, textPaint);// 血红蛋白
        canvas.drawText(accessoryExamination.getWbc(), 933, 1897, textPaint);// 白细胞
        canvas.drawText(accessoryExamination.getPlatelet(), 1239, 1897,
                textPaint);// 血小板
        canvas.drawText(accessoryExamination.getBloodOther(), 639, 1946,
                textPaint);// 血小常规其他
        canvas.drawText(accessoryExamination.getProteinuria(), 611, 1991,
                textPaint);// 尿蛋白
        canvas.drawText(accessoryExamination.getGlu(), 799, 1991, textPaint);// 尿糖
        canvas.drawText(accessoryExamination.getDka(), 1028, 1991, textPaint);// 尿酮体
        canvas.drawText(accessoryExamination.getOc(), 1272, 1991, textPaint);// 尿潜血
        canvas.drawText(accessoryExamination.getFbs(), 934, 2088, textPaint);// 餐前血糖
        canvas.drawText(accessoryExamination.getPbs(), 532, 2088, textPaint);// 餐后血糖
        canvas.drawText(accessoryExamination.getUrineOther(), 604, 2036,
                textPaint);// 尿常规其他
    }

    public static void drawBitmap3(Canvas canvas, base_info baseInfo,
                                   AccessoryExamination accessoryExamination, Examination examination,
                                   HealthAssessment healthAssessment) {
        canvas.drawText(accessoryExamination.getEcg(), 1548, 251,
                smallTextPaint);// 心电图
        // 如果心电结论大于20个字，就换行
        canvas.drawText(accessoryExamination.getEcgText(), 721, 210, textPaint);// 心电图描述
        canvas.drawText(accessoryExamination.getMalb(), 540, 354, textPaint);// 尿微量白蛋白
        canvas.drawText(accessoryExamination.getFob(), 1548, 408,
                smallTextPaint);// 大便潜血
        canvas.drawText(accessoryExamination.getHba1c(), 540, 471, textPaint);// 糖化血蛋白
        canvas.drawText(accessoryExamination.getHbsag(), 1548, 543,
                smallTextPaint);// 乙型肝炎表面抗原
        canvas.drawText(accessoryExamination.getAlt(), 760, 617, textPaint);// 血清谷丙转氨酶
        canvas.drawText(accessoryExamination.getAst(), 1201, 617, textPaint);// 血清谷草转氨酶
        canvas.drawText(accessoryExamination.getAlb(), 622, 662, textPaint);// 血蛋白
        canvas.drawText(accessoryExamination.getTbil(), 1139, 662, textPaint);// 总胆红素
        canvas.drawText(accessoryExamination.getDbil(), 677, 706, textPaint);// 结合胆红素
        canvas.drawText(accessoryExamination.getCr(), 668, 755, textPaint);// 血清肌酐
        canvas.drawText(accessoryExamination.getBun(), 1174, 755, textPaint);// 血尿素氮
        canvas.drawText(accessoryExamination.getKalemia(), 668, 799, textPaint);// 血钾浓度
        canvas.drawText(accessoryExamination.getNatremia(), 1174, 799,
                textPaint);// 血钠浓度
        canvas.drawText(accessoryExamination.getTc(), 645, 848, textPaint);// 总胆固醇
        canvas.drawText(accessoryExamination.getTg(), 1030, 848, textPaint);// 甘油三酯
        canvas.drawText(accessoryExamination.getLdl(), 866, 894, textPaint);// 血清低密度脂蛋白胆固醇
        canvas.drawText(accessoryExamination.getHdl(), 866, 937, textPaint);// 血清高密度脂蛋白胆固醇
        canvas.drawText(accessoryExamination.getX(), 1548, 984, smallTextPaint);// 胸部X线
        canvas.drawText(accessoryExamination.getXText(), 734, 990, textPaint);// 胸部X线描述
        canvas.drawText(accessoryExamination.getB(), 1548, 1036, smallTextPaint);// B超
        canvas.drawText(accessoryExamination.getBText(), 734, 1039, textPaint);// B超描述
        canvas.drawText(accessoryExamination.getPs(), 1548, 1089,
                smallTextPaint);// 宫颈涂片
        canvas.drawText(accessoryExamination.getPsText(), 734, 1094, textPaint);// 宫颈涂片描述
        canvas.drawText(accessoryExamination.getFuOther(), 555, 1144, textPaint);// 其他
        String recognize = healthAssessment.getRecognize();
        if (!TextUtils.isEmpty(recognize)) {
            String[] rs = recognize.split(",");
            for (int i = 0; i < rs.length; i++) {
                switch (rs[i]) {
                    case "11":
                        canvas.drawText("1", 1548, 1185, smallTextPaint);//
                        break;
                    case "12":
                        canvas.drawText("2", 1548, 1185, smallTextPaint);//
                        break;
                    case "21":
                        canvas.drawText("1", 1548, 1228, smallTextPaint);//
                        break;
                    case "22":
                        canvas.drawText("2", 1548, 1228, smallTextPaint);//
                        break;
                    case "31":
                        canvas.drawText("1", 1548, 1272, smallTextPaint);//
                        break;
                    case "32":
                        canvas.drawText("2", 1548, 1272, smallTextPaint);//
                        break;
                    case "41":
                        canvas.drawText("1", 1548, 1324, smallTextPaint);//
                        break;
                    case "42":
                        canvas.drawText("2", 1548, 1324, smallTextPaint);//
                        break;
                    case "51":
                        canvas.drawText("1", 1548, 1376, smallTextPaint);//
                        break;
                    case "52":
                        canvas.drawText("2", 1548, 1376, smallTextPaint);//
                        break;
                    case "61":
                        canvas.drawText("1", 1548, 1434, smallTextPaint);//
                        break;
                    case "62":
                        canvas.drawText("2", 1548, 1434, smallTextPaint);//
                        break;
                    case "71":
                        canvas.drawText("1", 1548, 1489, smallTextPaint);//
                        break;
                    case "72":
                        canvas.drawText("2", 1548, 1489, smallTextPaint);//
                        break;
                    case "81":
                        canvas.drawText("1", 1548, 1547, smallTextPaint);//
                        break;
                    case "82":
                        canvas.drawText("2", 1548, 1547, smallTextPaint);//
                        break;
                    case "91":
                        canvas.drawText("1", 1548, 1603, smallTextPaint);//
                        break;
                    case "92":
                        canvas.drawText("2", 1548, 1603, smallTextPaint);//
                        break;
                    default:
                        break;
                }
            }
        }
        // 脑血管疾病
        String NXGJB1 = baseInfo.getCerebrovascularDiseases();
        if (NXGJB1 != null) {
            String[] nxgjb = NXGJB1.split(",");
            for (int i = 0; i < nxgjb.length; i++) {
                if (nxgjb[i].equals("9")) {
                    nxgjb[i] = "6";
                }
                if (!TextUtils.isEmpty(nxgjb[i])) {
                    canvas.drawText(nxgjb[i], 1394 + i * 40, 1693,
                            smallTextPaint);//
                }
            }
        }
        canvas.drawText(baseInfo.getOthercerebrovascularDiseases(), 619, 1699,
                textPaint);// 脑血管疾病其他

        // 肾脏疾病
        String SZJB01 = baseInfo.getKidneyDiseases();
        if (SZJB01 != null) {
            String[] szjb01 = SZJB01.split(",");
            for (int i = 0; i < szjb01.length; i++) {
                if (szjb01[i].equals("9")) {
                    szjb01[i] = "6";
                }
                if (!TextUtils.isEmpty(szjb01[i])) {
                    canvas.drawText(szjb01[i], 1394 + i * 40, 1800,
                            smallTextPaint);//
                }
            }
        }
        canvas.drawText(baseInfo.getOtherkidneyDiseases(), 619, 1806, textPaint);// 肾脏疾病其他
        // 心脏疾病
        String XZJB01 = baseInfo.getHeartDisease();
        if (XZJB01 != null) {
            String[] xzjb01 = XZJB01.split(",");
            for (int i = 0; i < xzjb01.length; i++) {
                if (xzjb01[i].equals("9")) {
                    xzjb01[i] = "7";
                }
                if (!TextUtils.isEmpty(xzjb01[i])) {
                    canvas.drawText(xzjb01[i], 1394 + i * 40, 1906,
                            smallTextPaint);//
                }
            }
        }
        canvas.drawText(baseInfo.getOtherheartDisease(), 817, 1910, textPaint);// 肾脏疾病其他
        // 血管疾病
        String XGJB01 = baseInfo.getVascularDisease();
        if (XGJB01 != null) {
            String[] xgjb01 = XGJB01.split(",");
            for (int i = 0; i < xgjb01.length; i++) {
                if (xgjb01[i].equals("9")) {
                    xgjb01[i] = "4";
                }
                if (!TextUtils.isEmpty(xgjb01[i])) {
                    canvas.drawText(xgjb01[i], 1450 + i * 42, 1955,
                            smallTextPaint);//
                }
            }
        }
        canvas.drawText(baseInfo.getOtherVascularDisease(), 1182, 1961,
                textPaint);// 血管疾病其他
        // eyeDiseases眼部疾病
        String YBJB01 = baseInfo.getEyeDiseases();
        if (YBJB01 != null) {
            String[] ybjb01 = YBJB01.split(",");
            for (int i = 0; i < ybjb01.length; i++) {
                if (ybjb01[i].equals("9")) {
                    ybjb01[i] = "5";
                }
                if (!TextUtils.isEmpty(ybjb01[i])) {
                    canvas.drawText(ybjb01[i], 1458 + i * 42, 2035,
                            smallTextPaint);//
                }
            }
        }
        canvas.drawText(baseInfo.getOthereyeDiseases(), 624, 2057, textPaint);// 眼部疾病其他
        canvas.drawText(baseInfo.getNeurologicalDiseases(), 1548, 2113,
                smallTextPaint);// 精神系统疾病
        canvas.drawText(baseInfo.getNeurologicalDiseasesDesc(), 719, 2116,
                textPaint);// 精神系统疾病描述
        canvas.drawText(baseInfo.getOtherDiseasesone(), 1548, 2168,
                smallTextPaint);// 其他系统疾病
        canvas.drawText(baseInfo.getOtherDiseasesoneDesc(), 719, 2170,
                textPaint);// 其他系统疾病描述
    }

    public static void drawBitmap4(Canvas canvas, base_info baseInfo,
                                   HealthAssessment healthAssessment) {
        List<InhospitalSituation> inhospitalSituations = baseInfo
                .getInhospitalSituations();
        textPaint.setTextSize(23);
        if (inhospitalSituations != null && inhospitalSituations.size() > 0) {
            int type1count = 0;
            int type2count = 0;
            for (int i = 0; i < inhospitalSituations.size(); i++) {
                InhospitalSituation bean = inhospitalSituations.get(i);
                if (bean.getType().equals("1")) {
                    if (type1count == 0) {
                        canvas.drawText(bean.getInhospitalDate(), 511, 265,
                                textPaint);//
                        canvas.drawText(bean.getOuthospitalDate(), 656, 265,
                                textPaint);//
                        canvas.drawText(bean.getInhospitalReason(), 794, 265,
                                textPaint);//
                        canvas.drawText(bean.getMedicalestablishmentName(),
                                988, 265, textPaint);//
                        canvas.drawText(bean.getMedicalrecordNumber(), 1291,
                                265, textPaint);//
                        type1count = 1;
                    } else if (type1count == 1) {
                        canvas.drawText(bean.getInhospitalDate(), 511, 317,
                                textPaint);//
                        canvas.drawText(bean.getOuthospitalDate(), 656, 317,
                                textPaint);//
                        canvas.drawText(bean.getInhospitalReason(), 794, 317,
                                textPaint);//
                        canvas.drawText(bean.getMedicalestablishmentName(),
                                988, 317, textPaint);//
                        canvas.drawText(bean.getMedicalrecordNumber(), 1291,
                                317, textPaint);//
                        type1count = 2;
                    }
                } else if (bean.getType().equals("2")) {
                    if (type2count == 0) {
                        canvas.drawText(bean.getInhospitalDate(), 511, 422,
                                textPaint);//
                        canvas.drawText(bean.getOuthospitalDate(), 656, 422,
                                textPaint);//
                        canvas.drawText(bean.getInhospitalReason(), 794, 422,
                                textPaint);//
                        canvas.drawText(bean.getMedicalestablishmentName(),
                                988, 422, textPaint);//
                        canvas.drawText(bean.getMedicalrecordNumber(), 1291,
                                422, textPaint);//
                        type2count = 1;
                    } else if (type2count == 1) {
                        canvas.drawText(bean.getInhospitalDate(), 511, 472,
                                textPaint);//
                        canvas.drawText(bean.getOuthospitalDate(), 656, 472,
                                textPaint);//
                        canvas.drawText(bean.getInhospitalReason(), 794, 472,
                                textPaint);//
                        canvas.drawText(bean.getMedicalestablishmentName(),
                                988, 472, textPaint);//
                        canvas.drawText(bean.getMedicalrecordNumber(), 1291,
                                472, textPaint);//
                        type2count = 2;
                    }
                }
            }
        }
        textPaint.setTextSize(textSize);
        // 用药情况
        List<MedicineSituation> medicineSituations = baseInfo
                .getMedicineSituations();
        for (int i = 0; i < medicineSituations.size() && i < 6; i++) {
            MedicineSituation bean = medicineSituations.get(i);
            canvas.drawText(bean.getMedicine(), 284, 644 + 63 * i, textPaint);//
            canvas.drawText(bean.getUse(), 521, 644 + 63 * i, textPaint);//
            canvas.drawText(bean.getEachDose(), 730, 644 + 63 * i, textPaint);//
            canvas.drawText(bean.getUseDate(), 852, 644 + 63 * i, textPaint);//
            canvas.drawText(bean.getMedicineYield(), 1273, 644 + 63 * i,
                    textPaint);//
        }
        // 免疫接种情况
        List<NonimmuneInoculation> nonimmuneInoculations = baseInfo
                .getNonimmuneInoculations();
        for (int i = 0; i < nonimmuneInoculations.size(); i++) {
            NonimmuneInoculation bean = nonimmuneInoculations.get(i);
            canvas.drawText(bean.getName(), 284, 1083 + 63 * i, textPaint);//
            canvas.drawText(bean.getInoculationDate(), 521, 1083 + 63 * i,
                    textPaint);//
            canvas.drawText(bean.getInoculationUnit(), 740, 1083 + 63 * i,
                    textPaint);//
        }
        // 体检异常
        canvas.drawText(healthAssessment.getAbnormality(), 1548, 1264,
                smallTextPaint);//
        canvas.drawText(healthAssessment.getAbnormality1(), 381, 1357,
                textPaint);//
        canvas.drawText(healthAssessment.getAbnormality2(), 381, 1402,
                textPaint);//
        canvas.drawText(healthAssessment.getAbnormality3(), 381, 1449,
                textPaint);//
        canvas.drawText(healthAssessment.getAbnormality4(), 381, 1486,
                textPaint);//
        // 健康指导
        String jkzd_sb = healthAssessment.getMana();
        String[] jkzds = jkzd_sb.split(",");
        for (int i = 0; i < jkzds.length; i++) {
            canvas.drawText(jkzds[i], 646 + 45 * i, 1763, smallTextPaint);//
        }
        // 危险因素
        String wxys = healthAssessment.getRiskfactorsControl();
        String[] wxyss = wxys.split(",");
        for (int i = 0; i < wxyss.length; i++) {
            canvas.drawText(wxyss[i], 1079 + 45 * i, 1569, smallTextPaint);//
        }
        // 减重目标
        canvas.drawText(healthAssessment.getTargetWeight(), 1030, 1685,
                textPaint);//
        // 建议接种疫苗
        canvas.drawText(healthAssessment.getVaccine(), 1030, 1742, textPaint);//
        // 其他
        canvas.drawText(healthAssessment.getPjOther(), 942, 1790, textPaint);//
    }

    /***
     * 老年人生活自理能力
     *
     * @param context
     */
    public static void createLNRSHZLNL_Bitmap(Context context, OldAssessment old) {
        System.gc();
        // 体检表1的画布，用来画好字。然后保存。
        Bitmap zlnlBitmap = getBitmapByResId(context, R.raw.zilinengli);
        Bitmap zlnl = Bitmap.createBitmap(zlnlBitmap.getWidth(),
                zlnlBitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(zlnl);
        canvas.drawBitmap(zlnlBitmap, 0, 0, null);
        zlnlBitmap.recycle();
        drawlnrshzlnl(canvas, old);
        String name = BaseActivity.getName();
        System.out.println("name是=" + name);
        String basePath = FileSaveUtil.getPrintPath_SHZL() + "/" + name;
        FileSaveUtil.saveBitmap(zlnl, basePath,
                "lnrzlnl.png");
        zlnl.recycle();
        Intent intent = new Intent();
        intent.setAction("android.intent.action.SEND_MULTIPLE");
        intent.setType("image/*");
        ArrayList<Uri> imageUris = new ArrayList<Uri>();
        File f1 = new File(basePath, "lnrzlnl.png");
        imageUris.add(Uri.fromFile(f1));
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
        context.startActivity(intent);
    }

    /**
     * 老年人生活自理能力
     *
     * @param canvas
     */
    public static void drawlnrshzlnl(Canvas canvas, OldAssessment old) {
        textPaint.setTextSize(40);
        String name = BaseActivity.getArchiveBean().getName();
        textPaint.setTextSize(textSize);
        canvas.drawText(name, 332, 280, textPaint);
        canvas.drawText(old.getFoodLevel(), 1313, 587, textPaint);
        canvas.drawText(old.getWashLevel(), 1313, 878, textPaint);
        canvas.drawText(old.getClothesLevel(), 1313, 1177, textPaint);
        canvas.drawText(old.getToiletLevel(), 1313, 1460, textPaint);
        canvas.drawText(old.getActivitiesLevel(), 1313, 1768, textPaint);
        canvas.drawText(old.getSelfCareAbilityLevel(), 1313, 1965, textPaint);
    }

    /***
     * 打印健康档案
     * @param context
     * @param archive
     * @param detail
     */
    public static void createJkdaBitmap(Context context, Archive archive,
                                        GetArchiveDetail detail) {
        System.gc();
        // 体检表1的画布，用来画好字。然后保存。
        Bitmap jkdaBitmap = getBitmapByResId(context, R.raw.jkda);
        Bitmap jkda = Bitmap.createBitmap(jkdaBitmap.getWidth(),
                jkdaBitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(jkda);
        canvas.drawBitmap(jkdaBitmap, 0, 0, null);
        jkdaBitmap.recycle();
        Bitmap fengmianBitmap = getBitmapByResId(context, R.raw.jkdafengmian);
        Bitmap fengmian = Bitmap.createBitmap(fengmianBitmap.getWidth(),
                fengmianBitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas2 = new Canvas(fengmian);
        canvas2.drawBitmap(fengmianBitmap, 0, 0, null);
        fengmianBitmap.recycle();
        drawjkda(canvas, archive);
        drawJkdaFengmian(canvas2, archive, detail);
        String name = BaseActivity.getName();
        String basePath = FileSaveUtil.getPrintPath_JKDA() + name;
        FileSaveUtil.saveBitmap(fengmian, basePath,
                "jkdaFengmian.png");
        FileSaveUtil.saveBitmap(jkda, basePath,
                "jkdaInfo.png");
        fengmian.recycle();
        jkda.recycle();
        Intent intent = new Intent();
        intent.setAction("android.intent.action.SEND_MULTIPLE");
        intent.setType("image/*");
        ArrayList<Uri> imageUris = new ArrayList<Uri>();
        File f1 = new File(basePath, "jkdaFengmian.png");
        File f2 = new File(basePath, "jkdaInfo.png");
        imageUris.add(Uri.fromFile(f1));
        imageUris.add(Uri.fromFile(f2));
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
        context.startActivity(intent);
    }

    public static void createJkdaBitmap(Context context,
                                        HealthRecord healthRecord) {
        System.gc();
        // 体检表1的画布，用来画好字。然后保存。
        Bitmap jkdaBitmap = getBitmapByResId(context, R.raw.jkda);
        Bitmap jkda = Bitmap.createBitmap(jkdaBitmap.getWidth(),
                jkdaBitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(jkda);
        canvas.drawBitmap(jkdaBitmap, 0, 0, null);
        jkdaBitmap.recycle();
        Bitmap fengmianBitmap = getBitmapByResId(context, R.raw.jkdafengmian);
        Bitmap fengmian = Bitmap.createBitmap(fengmianBitmap.getWidth(),
                fengmianBitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas2 = new Canvas(fengmian);
        canvas2.drawBitmap(fengmianBitmap, 0, 0, null);
        fengmianBitmap.recycle();

        drawjkda(canvas, healthRecord);
        drawJkdaFengmian(canvas2, healthRecord);
        FileSaveUtil.saveBitmap(fengmian, FileSaveUtil.getSDCardPath(),
                "jkdaFengmian.png");
        FileSaveUtil.saveBitmap(jkda, FileSaveUtil.getSDCardPath(),
                "jkdaInfo.png");
        fengmian.recycle();
        jkda.recycle();
        Intent intent = new Intent();
        intent.setAction("android.intent.action.SEND_MULTIPLE");
        intent.setType("image/*");
        ArrayList<Uri> imageUris = new ArrayList<Uri>();
        File f1 = new File(FileSaveUtil.getSDCardPath(), "jkdaFengmian.png");
        File f2 = new File(FileSaveUtil.getSDCardPath(), "jkdaInfo.png");
        imageUris.add(Uri.fromFile(f1));
        imageUris.add(Uri.fromFile(f2));
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
        context.startActivity(intent);
    }

    private static void drawjkda(Canvas canvas, HealthRecord healthRecord) {
        textPaint.setTextSize(40);
        canvas.drawText(healthRecord.getPersonName(), 432, 322, textPaint);
        textPaint.setTextSize(textSize);
        canvas.drawText(healthRecord.getSexCode(), 1063, 439, smallTextPaint);
        canvas.drawText(healthRecord.getBirthday(), 1249, 449, textPaint);// 出生日期
        canvas.drawText(healthRecord.getIdCard(), 408, 525, textPaint);// idcard
        canvas.drawText(healthRecord.getWorkPlace(), 1129, 525, textPaint);// 工作单位
        canvas.drawText(healthRecord.getPhoneNumber(), 401, 594, textPaint);// 个人电话
        canvas.drawText(healthRecord.getContact(), 903, 594, textPaint);// 联系人
        canvas.drawText(healthRecord.getContactPhone(), 1255, 594, textPaint);// 联系人电话
        canvas.drawText(healthRecord.getRegisteredPermanent(), 849, 650,
                smallTextPaint);// 户籍
        String minzu = healthRecord.getNationCode();
        if ("01".equals(minzu)) {
            canvas.drawText("1", 1575, 650, smallTextPaint);// 民族码
        } else {
            canvas.drawText("2", 1575, 650, smallTextPaint);// 民族码
            canvas.drawText(NationUtil.getNationStr(minzu), 1495, 656,
                    textPaint);// 民族名称
        }
        canvas.drawText(healthRecord.getBloodTypeCode(), 1522, 696,
                smallTextPaint);// 血型
        canvas.drawText(healthRecord.getRhBloodCode(), 1568, 696,
                smallTextPaint);// rh阴性
        // 文化程度
        String whcd = healthRecord.getEducationCode();
        switch (whcd) {
            case "90":
                whcd = "1";
                break;
            case "80":
                whcd = "2";
                break;
            case "70":
                whcd = "3";
                break;
            case "58":
                whcd = "4";
                break;
            case "27":
                whcd = "5";
                break;
            case "91":
                whcd = "6";
                break;
        }
        canvas.drawText(whcd, 1573, 741, smallTextPaint);// 文化程度
        String gongzuo = healthRecord.getWorkCode();
        if ("X".equals(gongzuo)) {
            gongzuo = "7";
        }
        if ("Y".equals(gongzuo)) {
            gongzuo = "8";
        }
        canvas.drawText(gongzuo, 1573, 868, smallTextPaint);// 工作
        String hunyin = healthRecord.getMaritalStatusCode();
        if ("9".equals(hunyin)) {
            hunyin = "5";
        }
        canvas.drawText(hunyin, 1573, 915, smallTextPaint);// 婚姻状况
        // 医疗付费方式
        String yblx = healthRecord.getInsuranceCode();
        String[] ylff = yblx.split(",");
        for (int i = 0; i < ylff.length; i++) {
            if ("99".equals(ylff[i])) {
                ylff[i] = "8";
            }
            canvas.drawText(ylff[i], 1479 + 46 * i, 984, smallTextPaint);// 付费方式
        }
        // 付费

        canvas.drawText(healthRecord.getInsuranceType(), 1241, 1007, textPaint);// 付费方式
        // 药物过敏
        String yaowu = "";
        String ywgm = healthRecord.getYwgms();
        String[] yawgms = ywgm.split(",");
        for (int i = 0; i < yawgms.length; i++) {
            if (yawgms[i].equals("030301")) {
                yawgms[i] = "1";
            }
            if (yawgms[i].equals("030302")) {
                yawgms[i] = "2";
            }
            if (yawgms[i].equals("030303")) {
                yawgms[i] = "3";
            }
            if (yawgms[i].equals("030304")) {
                yawgms[i] = "4";
            }
            if (yawgms[i].equals("030305")) {
                yawgms[i] = "5";
            }
            canvas.drawText(yawgms[i], 1435 + 45 * i, 1050, smallTextPaint);
        }
        canvas.drawText(healthRecord.getYwgmsqt(), 1113, 1054, textPaint);
        // 暴露史
        String grbls = healthRecord.getBls();
        String[] grblsxh = grbls.split(",");
        for (int i = 0; i < grblsxh.length; i++) {
            if (grblsxh[i].equals("151501")) {
                grblsxh[i] = "1";
            }
            if (grblsxh[i].equals("151502")) {
                grblsxh[i] = "2";
            }
            if (grblsxh[i].equals("151503")) {
                grblsxh[i] = "3";
            }
            if (grblsxh[i].equals("151504")) {
                grblsxh[i] = "4";
                canvas.drawText(grblsxh[i], 1480 + i * 45, 1095, smallTextPaint);
            }
        }
        List<jwsjb> jwsjbs = healthRecord.getJwsjbs();
        if (jwsjbs.size() > 0) {
            jwsjb j1 = jwsjbs.get(0);
            j1.getJwsjbmc();
            j1.getJwsjbqzsj();
            canvas.drawText(getJibingByCode(j1.getJwsjbcode()), 415, 1278,
                    smallTextPaint);
            if (!TextUtils.isEmpty(j1.getJwsjbqzsj())) {
                String year = j1.getJwsjbqzsj().substring(0, 4);
                String month = j1.getJwsjbqzsj().substring(5, 7);
                canvas.drawText(year, 581, 1283, textPaint);
                canvas.drawText(month, 676, 1283, textPaint);
            }
        }
        if (jwsjbs.size() > 1) {
            jwsjb j1 = jwsjbs.get(1);
            j1.getJwsjbmc();
            j1.getJwsjbqzsj();
            canvas.drawText(getJibingByCode(j1.getJwsjbcode()), 415, 1317,
                    smallTextPaint);
            if (!TextUtils.isEmpty(j1.getJwsjbqzsj())) {

                String year = j1.getJwsjbqzsj().substring(0, 4);
                String month = j1.getJwsjbqzsj().substring(5, 7);
                canvas.drawText(year, 581, 1322, textPaint);
                canvas.drawText(month, 676, 1322, textPaint);
            }
        }
        if (jwsjbs.size() > 2) {
            jwsjb j1 = jwsjbs.get(2);
            j1.getJwsjbmc();
            j1.getJwsjbqzsj();
            canvas.drawText(getJibingByCode(j1.getJwsjbcode()), 786, 1278,
                    smallTextPaint);
            if (!TextUtils.isEmpty(j1.getJwsjbqzsj())) {
                String year = j1.getJwsjbqzsj().substring(0, 4);
                String month = j1.getJwsjbqzsj().substring(5, 7);
                canvas.drawText(year, 965, 1283, textPaint);
                canvas.drawText(month, 1083, 1283, textPaint);
            }
        }

        if (jwsjbs.size() > 3) {
            jwsjb j1 = jwsjbs.get(3);
            j1.getJwsjbmc();
            j1.getJwsjbqzsj();
            canvas.drawText(getJibingByCode(j1.getJwsjbcode()), 786, 1317,
                    smallTextPaint);
            if (!TextUtils.isEmpty(j1.getJwsjbqzsj())) {

                String year = j1.getJwsjbqzsj().substring(0, 4);
                String month = j1.getJwsjbqzsj().substring(5, 7);
                canvas.drawText(year, 965, 1322, textPaint);
                canvas.drawText(month, 1083, 1322, textPaint);
            }
        }
        if (jwsjbs.size() > 4) {
            jwsjb j1 = jwsjbs.get(4);
            j1.getJwsjbmc();
            j1.getJwsjbqzsj();
            canvas.drawText(getJibingByCode(j1.getJwsjbcode()), 1203, 1278,
                    smallTextPaint);
            if (!TextUtils.isEmpty(j1.getJwsjbqzsj())) {

                String year = j1.getJwsjbqzsj().substring(0, 4);
                String month = j1.getJwsjbqzsj().substring(5, 7);
                canvas.drawText(year, 1371, 1283, textPaint);
                canvas.drawText(month, 1484, 1283, textPaint);
            }
        }

        if (jwsjbs.size() > 5) {
            jwsjb j1 = jwsjbs.get(5);
            j1.getJwsjbmc();
            j1.getJwsjbqzsj();
            canvas.drawText(getJibingByCode(j1.getJwsjbcode()), 1203, 1317,
                    smallTextPaint);
            if (!TextUtils.isEmpty(j1.getJwsjbqzsj())) {

                String year = j1.getJwsjbqzsj().substring(0, 4);
                String month = j1.getJwsjbqzsj().substring(5, 7);
                canvas.drawText(year, 1371, 1322, textPaint);
                canvas.drawText(month, 1484, 1322, textPaint);
            }
        }
        List<jwsss> jwssss = healthRecord.getJwssss();
        if (jwssss.size() > 0) {
            jwsss j = jwssss.get(0);
            canvas.drawText(j.getJwsssmc(), 698, 1384, textPaint);
            textPaint.setTextSize(24);
            canvas.drawText(j.getJwsssqzsj(), 930, 1384, textPaint);
            textPaint.setTextSize(textSize);
        }
        if (jwssss.size() > 1) {
            jwsss j = jwssss.get(1);
            canvas.drawText(j.getJwsssmc(), 1141, 1384, textPaint);
            canvas.drawText(j.getJwsssqzsj(), 1374, 1384, textPaint);
        }
        List<jwsws> jwswss = healthRecord.getJwswss();
        if (jwswss.size() > 0) {
            jwsws j = jwswss.get(0);
            canvas.drawText(j.getJwswsmc(), 698, 1429, textPaint);
            textPaint.setTextSize(24);
            canvas.drawText(j.getJwswsqzsj(), 930, 1429, textPaint);
            textPaint.setTextSize(textSize);
        }
        if (jwswss.size() > 1) {
            jwsws j = jwswss.get(1);
            canvas.drawText(j.getJwswsmc(), 1141, 1429, textPaint);
            canvas.drawText(j.getJwswsqzsj(), 1374, 1429, textPaint);
        }

        List<jwssx> jwssxs = healthRecord.getJwssxs();
        if (jwssxs.size() > 0) {
            jwssx j = jwssxs.get(0);
            canvas.drawText(j.getJwssxyy(), 698, 1475, textPaint);
            textPaint.setTextSize(24);
            canvas.drawText(j.getJwssxqzsj(), 930, 1475, textPaint);
            textPaint.setTextSize(textSize);
        }
        if (jwswss.size() > 1) {
            jwssx j = jwssxs.get(1);
            canvas.drawText(j.getJwssxyy(), 1141, 1475, textPaint);
            canvas.drawText(j.getJwssxqzsj(), 1374, 1475, textPaint);
        }
        // 父亲的
        // getJzsfqqt
        String fuqin = healthRecord.getJzsfq();
        String[] fuqins = fuqin.split(",");
        for (int i = 0; i < fuqins.length; i++) {
            canvas.drawText(getFuqinByCode(fuqins[i]), 612 + i * 45, 1516,
                    smallTextPaint);
        }
        canvas.drawText(healthRecord.getJzsfqqt(), 872, 1520, textPaint);
        // 母亲的。
        String muqin = healthRecord.getJzsmq();
        String[] muqins = muqin.split(",");
        for (int i = 0; i < muqins.length; i++) {
            canvas.drawText(getMuqinByCode(muqins[i]), 1205 + i * 45, 1516,
                    smallTextPaint);
        }
        canvas.drawText(healthRecord.getJzsmqqt(), 1468, 1520, textPaint);
        // 兄弟姐妹
        String xiongdi = healthRecord.getJzsxdjm();
        String[] xiongdis = xiongdi.split(",");
        for (int i = 0; i < xiongdis.length; i++) {
            canvas.drawText(getXiongdiByCode(xiongdis[i]), 612 + i * 45, 1561,
                    smallTextPaint);
        }
        canvas.drawText(healthRecord.getJzsxdjmqt(), 872, 1564, textPaint);
        // 子女
        String zinv = healthRecord.getJzszn();
        String[] zinvs = zinv.split(",");
        for (int i = 0; i < zinvs.length; i++) {
            canvas.drawText(getZinvByCode(zinvs[i]), 1205 + i * 45, 1561,
                    smallTextPaint);
        }
        canvas.drawText(healthRecord.getJzsznqt(), 1468, 1564, textPaint);
        // 遗传病史
        String yichuanbing = healthRecord.getYcbs();
        if ("121201".equals(yichuanbing)) {
            yichuanbing = "1";
        } else if (yichuanbing.contains("121212")) {
            yichuanbing = "2";
        }
        canvas.drawText(yichuanbing, 1573, 1716, smallTextPaint);
        canvas.drawText(healthRecord.getYcbsmc(), 718, 1720, textPaint);
        // 残疾情况
        String chanji = healthRecord.getCjqk();
        String[] chanjis = chanji.split(",");
        for (int i = 0; i < chanjis.length; i++) {
            if (chanjis[i].equals("141401")) {
                chanjis[i] = "1";
            }
            if (chanjis[i].equals("141402")) {
                chanjis[i] = "2";
            }
            if (chanjis[i].equals("141403")) {
                chanjis[i] = "3";
            }
            if (chanjis[i].equals("141413")) {
                chanjis[i] = "4";
            }
            if (chanjis[i].equals("141405")) {
                chanjis[i] = "5";
            }
            if (chanjis[i].equals("141406")) {
                chanjis[i] = "6";
            }
            if (chanjis[i].equals("141407")) {
                chanjis[i] = "7";
            }
            if (chanjis[i].equals("141412")) {
                chanjis[i] = "8";
            }
            canvas.drawText(chanjis[i], 1348 + 45 * i, 1823, smallTextPaint);

        }
        canvas.drawText(healthRecord.getCjqkqt(), 918, 1827, smallTextPaint);
        canvas.drawText(healthRecord.getCfpfss(), 1572, 1866, smallTextPaint);// 厨房
        canvas.drawText(healthRecord.getRllx(), 1572, 1922, smallTextPaint);// 燃料
        canvas.drawText(healthRecord.getYs(), 1572, 1980, smallTextPaint);// 饮水
        canvas.drawText(healthRecord.getCs(), 1572, 2042, smallTextPaint);// 厕所
        canvas.drawText(healthRecord.getQsl(), 1572, 2108, smallTextPaint);//
    }

    public static void drawjkda(Canvas canvas, Archive archive) {
        textPaint.setTextSize(40);
        canvas.drawText(archive.getPersonName(), 432, 322, textPaint);
        textPaint.setTextSize(textSize);
        canvas.drawText(archive.getSexCode(), 1063, 439, smallTextPaint);
        canvas.drawText(archive.getBirthday(), 1249, 449, textPaint);// 出生日期
        canvas.drawText(archive.getIdCard(), 408, 525, textPaint);// idcard
        ArchiveDetail archiveDetail = archive.getArchiveDetail();
        // canvas.drawText(archiveDetailVO.getwo(), 1129, 525, textPaint);//
        // 工作单位
        canvas.drawText(archive.getMobileNumber(), 401, 594, textPaint);// 个人电话
        canvas.drawText(archiveDetail.getContact(), 903, 594, textPaint);// 联系人
        canvas.drawText(archiveDetail.getContactPhone(), 1255, 594, textPaint);// 联系人电话
        canvas.drawText(archiveDetail.getRegisteredPermanent(), 849, 650,
                smallTextPaint);// 户籍
        String minzu = archiveDetail.getNationCode();
        if ("01".equals(minzu)) {
            canvas.drawText("1", 1575, 650, smallTextPaint);// 民族码
        } else {
            canvas.drawText("2", 1575, 650, smallTextPaint);// 民族码
            canvas.drawText(NationUtil.getNationStr(minzu), 1495, 656,
                    textPaint);// 民族名称
        }
        canvas.drawText(archiveDetail.getBloodTypeCode(), 1522, 696,
                smallTextPaint);// 血型
        canvas.drawText(archiveDetail.getRhBloodCode(), 1568, 696,
                smallTextPaint);// rh阴性
        // 文化程度
        String whcd = archiveDetail.getEducationCode();
        switch (whcd) {
            case 11 + "":
            case 21 + "":
            case 31 + "":
                whcd = "5";
                break;
            case 41 + "":
            case 50 + "":
            case 61 + "":
                whcd = "4";
                break;
            case 71 + "":
                whcd = "3";
                break;
            case 81 + "":
                whcd = "2";
                break;
            case 90 + "":
                whcd = "1";
                break;
            case 01 + "":
                whcd = "6";
                break;
        }
        canvas.drawText(whcd, 1573, 741, smallTextPaint);// 文化程度
        String gongzuo = archiveDetail.getWorkCode();
        switch (gongzuo) {
            case "0":
                gongzuo = "1";
                break;
            case "1/2":
                gongzuo = "2";
                break;
            case "3":
                gongzuo = "3";
                break;
            case "4":
                gongzuo = "4";
                break;
            case "5":
                gongzuo = "5";
                break;
            case "9-9":
                gongzuo = "6";
                break;
            case "X":
                gongzuo = "7";
                break;
            case "Y":
                gongzuo = "8";
                break;
            case "Z":
                // gongzuo="1";
                break;
        }
        canvas.drawText(gongzuo, 1573, 868, smallTextPaint);// 工作
        String hyzk = archiveDetail.getMaritalStatusCode();
        switch (hyzk) {
            case 10 + "":
                hyzk = "1";
                break;
            case 20 + "":
            case 21 + "":
            case 22 + "":
            case 23 + "":
                hyzk = "2";
                break;
            case 30 + "":
                hyzk = "3";
                break;
            case 40 + "":
                hyzk = "4";
                break;
            case 50 + "":
                hyzk = "5";
                break;
        }
        canvas.drawText(hyzk, 1573, 915, smallTextPaint);// 婚姻状况
        // 医疗付费方式
        String yblx = archiveDetail.getInsuranceCode();
        canvas.drawText(yblx, 1479 + 46 * 0, 984, smallTextPaint);// 付费方式
        // canvas.drawText(healthRecord.getInsuranceType(), 1241, 1007,
        // textPaint);// 不知道是什么

        List<PastHistorylist> jwsList = archive.getPastHistorylist();
        if (jwsList == null || jwsList.size() <= 0) {
            return;
        }
        // jwsListStr = JibingContants.getArrayByCode(jwsList);
        // 药物过敏
        List<PastHistorylist> ywgmsList = JibingContants
                .getPastHistorylistsByType(jwsList,
                        JibingContants.BM.YWGMS.class);
        for (int i = 0; i < ywgmsList.size(); i++) {
            String code = ywgmsList.get(i).getDiseaseCode();
            if (code.equals("0101")) {
                code = "1";
            }
            if (code.equals("0102")) {
                code = "2";
            }
            if (code.equals("0103")) {
                code = "3";
            }
            if (code.equals("0104")) {
                code = "4";
            }
            if (code.equals("0109")) {
                code = "5";
            }
            canvas.drawText(code, 1435 + 45 * i, 1050, smallTextPaint);
        }
        // canvas.drawText(healthRecord.getYwgmsqt(), 1113, 1054,
        // textPaint);//药物过敏史其他
        // 暴露史
        List<PastHistorylist> blsList = JibingContants
                .getPastHistorylistsByType(jwsList, JibingContants.BM.BLS.class);
        for (int i = 0; i < blsList.size(); i++) {
            String code = blsList.get(i).getDiseaseCode();
            if (code.equals("1201")) {
                code = "1";
            }
            if (code.equals("1202")) {
                code = "2";
            }
            if (code.equals("1203")) {
                code = "3";
            }
            if (code.equals("1204")) {
                code = "4";
                canvas.drawText(code, 1480 + i * 45, 1095, smallTextPaint);
            }
        }
        // 疾病史
        List<PastHistorylist> jbsList = JibingContants
                .getPastHistorylistsByType(jwsList, JibingContants.BM.JBS.class);
        for (int i = 0; i < jbsList.size(); i++) {
            String code = jbsList.get(i).getDiseaseCode();

        }
        if (jbsList != null) {
            if (jbsList.size() > 0) {
                PastHistorylist bean = jbsList.get(0);
                canvas.drawText(getJibingByCode(bean.getDiseaseCode()), 415,
                        1278, smallTextPaint);
                // 确诊时间
                String qzsj = bean.getConfirmDate();
                if (!TextUtils.isEmpty(qzsj)) {
                    String year = qzsj.substring(0, 4);
                    String month = qzsj.substring(5, 7);
                    canvas.drawText(year, 581, 1283, textPaint);
                    canvas.drawText(month, 676, 1283, textPaint);
                }
            }
            if (jbsList.size() > 1) {
                PastHistorylist bean = jbsList.get(1);
                canvas.drawText(getJibingByCode(bean.getDiseaseCode()), 415,
                        1317, smallTextPaint);
                // 确诊时间
                String qzsj = bean.getConfirmDate();
                if (!TextUtils.isEmpty(qzsj)) {
                    String year = qzsj.substring(0, 4);
                    String month = qzsj.substring(5, 7);
                    canvas.drawText(year, 581, 1322, textPaint);
                    canvas.drawText(month, 676, 1322, textPaint);
                }
            }
            if (jbsList.size() > 2) {
                PastHistorylist bean = jbsList.get(2);
                canvas.drawText(getJibingByCode(bean.getDiseaseCode()), 786,
                        1278, smallTextPaint);
                // 确诊时间
                String qzsj = bean.getConfirmDate();
                if (!TextUtils.isEmpty(qzsj)) {
                    String year = qzsj.substring(0, 4);
                    String month = qzsj.substring(5, 7);
                    canvas.drawText(year, 965, 1283, textPaint);
                    canvas.drawText(month, 1083, 1283, textPaint);
                }
            }
            if (jbsList.size() > 3) {
                PastHistorylist bean = jbsList.get(3);
                canvas.drawText(getJibingByCode(bean.getDiseaseCode()), 786,
                        1317, smallTextPaint);
                // 确诊时间
                String qzsj = bean.getConfirmDate();
                if (!TextUtils.isEmpty(qzsj)) {
                    String year = qzsj.substring(0, 4);
                    String month = qzsj.substring(5, 7);
                    canvas.drawText(year, 965, 1322, textPaint);
                    canvas.drawText(month, 1083, 1322, textPaint);
                }
            }
            if (jbsList.size() > 4) {
                PastHistorylist bean = jbsList.get(4);
                canvas.drawText(getJibingByCode(bean.getDiseaseCode()), 1203,
                        1278, smallTextPaint);
                // 确诊时间
                String qzsj = bean.getConfirmDate();
                if (!TextUtils.isEmpty(qzsj)) {
                    String year = qzsj.substring(0, 4);
                    String month = qzsj.substring(5, 7);
                    canvas.drawText(year, 1371, 1283, textPaint);
                    canvas.drawText(month, 1484, 1283, textPaint);
                }
            }
            if (jbsList.size() > 5) {
                PastHistorylist bean = jbsList.get(5);
                canvas.drawText(getJibingByCode(bean.getDiseaseCode()), 1203,
                        1317, smallTextPaint);
                // 确诊时间
                String qzsj = bean.getConfirmDate();
                if (!TextUtils.isEmpty(qzsj)) {
                    String year = qzsj.substring(0, 4);
                    String month = qzsj.substring(5, 7);
                    canvas.drawText(year, 1371, 1322, textPaint);
                    canvas.drawText(month, 1484, 1322, textPaint);
                }
            }
        }

        // 手术史
        List<PastHistorylist> sssList = JibingContants
                .getPastHistorylistsByType(jwsList, JibingContants.BM.SSS.class);
        if (sssList != null) {
            if (sssList.size() > 0) {
                PastHistorylist bean = sssList.get(0);
                // 手术史的疾病名称
                canvas.drawText(
                        JibingContants.getStringByBM("03",
                                bean.getDiseaseCode()), 698, 1384, textPaint);
                textPaint.setTextSize(24);
                canvas.drawText(bean.getConfirmDate(), 930, 1384, textPaint);
                textPaint.setTextSize(textSize);
            }
            if (sssList.size() > 1) {
                PastHistorylist bean = sssList.get(1);
                // 手术史的疾病名称
                canvas.drawText(
                        JibingContants.getStringByBM("03",
                                bean.getDiseaseCode()), 1141, 1384, textPaint);
                textPaint.setTextSize(24);
                canvas.drawText(bean.getConfirmDate(), 1374, 1384, textPaint);
                textPaint.setTextSize(textSize);
            }
        }
        // 外伤史
        List<PastHistorylist> wssList = JibingContants
                .getPastHistorylistsByType(jwsList, JibingContants.BM.WSS.class);
        if (wssList != null) {
            if (wssList.size() > 0) {
                PastHistorylist bean = wssList.get(0);
                canvas.drawText(
                        JibingContants.getStringByBM("06",
                                bean.getDiseaseCode()), 698, 1429, textPaint);
                textPaint.setTextSize(24);
                canvas.drawText(bean.getConfirmDate(), 930, 1429, textPaint);
                textPaint.setTextSize(textSize);
            }
            if (wssList.size() > 1) {
                PastHistorylist bean = wssList.get(1);
                canvas.drawText(
                        JibingContants.getStringByBM("06",
                                bean.getDiseaseCode()), 1141, 1429, textPaint);
                textPaint.setTextSize(24);
                canvas.drawText(bean.getConfirmDate(), 1374, 1429, textPaint);
                textPaint.setTextSize(textSize);
            }
        }
        // 输血史
        List<PastHistorylist> sxsList = JibingContants
                .getPastHistorylistsByType(jwsList, JibingContants.BM.SXS.class);
        if (sxsList != null) {
            if (sxsList.size() > 0) {
                PastHistorylist bean = sxsList.get(0);
                canvas.drawText(
                        JibingContants.getStringByBM("04",
                                bean.getDiseaseCode()), 698, 1475, textPaint);
                textPaint.setTextSize(24);
                canvas.drawText(bean.getConfirmDate(), 930, 1475, textPaint);
                textPaint.setTextSize(textSize);
            }
            if (sxsList.size() > 1) {
                PastHistorylist bean = sxsList.get(1);
                canvas.drawText(
                        JibingContants.getStringByBM("04",
                                bean.getDiseaseCode()), 1141, 1475, textPaint);
                textPaint.setTextSize(24);
                canvas.drawText(bean.getConfirmDate(), 1374, 1475, textPaint);
                textPaint.setTextSize(textSize);
            }
        }
        // 父亲的
        List<PastHistorylist> fqList = JibingContants
                .getPastHistorylistsByType(jwsList,
                        JibingContants.BM.JZJBS_FQ.class);
        if (fqList != null) {
            if (fqList.size() > 0) {
                for (int i = 0; i < fqList.size(); i++) {
                    PastHistorylist bean = fqList.get(i);
                    canvas.drawText(getFuqinByCode(bean.getDiseaseCode()),
                            612 + i * 45, 1516, smallTextPaint);
                }
            }
        }
        // 父亲的其他病的名称
        // canvas.drawText(healthRecord.getJzsfqqt(), 872, 1520, textPaint);

        // 母亲的
        List<PastHistorylist> mqList = JibingContants
                .getPastHistorylistsByType(jwsList,
                        JibingContants.BM.JZJBS_MQ.class);
        if (mqList != null) {
            if (mqList.size() > 0) {
                for (int i = 0; i < mqList.size(); i++) {
                    PastHistorylist bean = mqList.get(i);
                    canvas.drawText(getMuqinByCode(bean.getDiseaseCode()),
                            1205 + i * 45, 1516, smallTextPaint);
                }
            }
        }
        // 母亲的其他病的名称
        // canvas.drawText(healthRecord.getJzsmqqt(), 1468, 1520, textPaint);

        // 兄弟姐妹
        List<PastHistorylist> xdjmList = JibingContants
                .getPastHistorylistsByType(jwsList,
                        JibingContants.BM.JZJBS_XDJM.class);
        if (xdjmList != null) {
            if (xdjmList.size() > 0) {
                for (int i = 0; i < xdjmList.size(); i++) {
                    PastHistorylist bean = xdjmList.get(i);
                    canvas.drawText(getXiongdiByCode(bean.getDiseaseCode()),
                            612 + i * 45, 1561, smallTextPaint);
                }
            }
        }
        // 兄弟姐妹的其他病的名称
        // canvas.drawText(healthRecord.getJzsxdjmqt(), 872, 1564, textPaint);

        // 子女
        List<PastHistorylist> znList = JibingContants
                .getPastHistorylistsByType(jwsList,
                        JibingContants.BM.JZJBS_ZN.class);
        if (znList != null) {
            if (znList.size() > 0) {
                for (int i = 0; i < znList.size(); i++) {
                    PastHistorylist bean = znList.get(i);
                    canvas.drawText(getZinvByCode(bean.getDiseaseCode()),
                            1205 + i * 45, 1561, smallTextPaint);
                }
            }
        }
        // 子女的其他病的名称
        // canvas.drawText(healthRecord.getJzsznqt(), 1468, 1564, textPaint);

        // 遗传病史
        List<PastHistorylist> ycbsList = JibingContants
                .getPastHistorylistsByType(jwsList,
                        JibingContants.BM.YCBS.class);
        for (int i = 0; i < ycbsList.size(); i++) {
            PastHistorylist bean = ycbsList.get(i);
            String yichuanbing = bean.getDiseaseCode();
            if ("0501".equals(yichuanbing)) {
                yichuanbing = "1";
            } else if ("0501".contains("121212")) {
                yichuanbing = "2";
            }
            canvas.drawText(yichuanbing, 1573, 1716, smallTextPaint);
            // 显示遗传病史的疾病名。
            // canvas.drawText(healthRecord.getYcbsmc(), 718, 1720, textPaint);
        }
        // 残疾情况
        List<PastHistorylist> cjzkList = JibingContants
                .getPastHistorylistsByType(jwsList,
                        JibingContants.BM.CJZK.class);
        for (int i = 0; i < cjzkList.size(); i++) {
            PastHistorylist bean = cjzkList.get(i);
            String code = bean.getDiseaseCode();
            // <item text="残疾状况">
            // <item key="1101" text="无残疾" />1
            // <item key="1102" text="视力残疾" />2
            // <item key="1103" text="听力残疾 " />3
            // <item key="1104" text="言语残疾" />4
            // <item key="1105" text="肢体残疾" />5
            // <item key="1106" text="智力残疾" />6
            // <item key="1107" text="精神残疾" />7
            // <item key="1108" text="孤独症儿童" />
            // <item key="1109" text="脑瘫儿童" />
            // <item key="1199" text="其他残疾" />
            // </item>)
            if (code.equals("1101")) {
                code = "1";
            }
            if (code.equals("1102")) {
                code = "2";
            }
            if (code.equals("1103")) {
                code = "3";
            }
            if (code.equals("1114")) {
                code = "4";
            }
            if (code.equals("1105")) {
                code = "5";
            }
            if (code.equals("1106")) {
                code = "6";
            }
            if (code.equals("1107")) {
                code = "7";
            }
            if (code.equals("1108")) {
                canvas.drawText("孤独症儿童", 918, 1827, smallTextPaint);
            }
            if (code.equals("1109")) {
                canvas.drawText("脑瘫儿童", 918, 1827, smallTextPaint);
            }
            if (code.equals("1199")) {
                canvas.drawText("其他", 918, 1827, smallTextPaint);
            }
            canvas.drawText(code, 1348 + 45 * i, 1823, smallTextPaint);
            // 没填写其他的疾病的名称
        }
        String chufang = archiveDetail.getCookAirTool();
        if (!"9".equals(chufang)) {
            canvas.drawText(chufang, 1572, 1866, smallTextPaint);// 厨房
        }
        String ranliao = archiveDetail.getFuelType();
        if (!"9".equals(ranliao)) {
            canvas.drawText(ranliao, 1572, 1922, smallTextPaint);// 燃料
        }
        String cesuo = archiveDetail.getWashroom();
        if (!"9".equals(cesuo)) {
            canvas.drawText(cesuo, 1572, 2042, smallTextPaint);// 厕所
        }
        String yinshui = archiveDetail.getWaterSourceCode();
        if (!"9".equals(yinshui)) {
            canvas.drawText(yinshui, 1572, 1980, smallTextPaint);// 饮水
        }
        String qinchulan = archiveDetail.getLivestockColumn();
        canvas.drawText(qinchulan, 1572, 2108, smallTextPaint);// 禽畜栏
    }

    public static void drawJkdaFengmian(Canvas canvas, Archive archive,
                                        GetArchiveDetail detail) {
        HealthRecord healthRecord = null;
        textPaint.setTextSize(40);
        canvas.drawText(archive.getPersonName(), 663, 609, textPaint);// 个人姓名
        // canvas.drawText(healthRecord.getAddress(), 663, 766,
        // textPaint);//现住地址 这个暂时不填*****
        textPaint.setTextSize(26);
        canvas.drawText(archive.getRegionCode_text(), 663, 923, textPaint);// 户籍地址
        textPaint.setTextSize(40);
        canvas.drawText(archive.getMobileNumber(), 663, 1081, textPaint);// 联系电话
        // canvas.drawText(healthRecord.getPersonName(), 831, 1238,
        // textPaint);//街道名称 这个不知道什么。不填****
        // canvas.drawText(healthRecord.getPersonName(), 831, 1238,
        // textPaint);//村委会、居委会名称 不填*******
        // canvas.drawText(healthRecord.getPersonName(), 663, 1552,
        // textPaint);//建档单位 不填********
        // canvas.drawText(healthRecord.getPersonName(), 663, 1630,
        // textPaint);//建档人 不填*******
        // canvas.drawText(healthRecord.get(), 663, 1708, textPaint);//责任医生
        // String createTime = archive.getCreateTime();
        // if (createTime.length() >= 10) {
        // String year = createTime.substring(0, 4);
        // String month = createTime.substring(5, 7);
        // String day = createTime.substring(8, 10);
        // canvas.drawText(year, 663, 1776, textPaint);// 建档日期 年
        // canvas.drawText(month, 902, 1776, textPaint);// 建档日期 月
        // canvas.drawText(day, 1028, 1776, textPaint);// 建档日期 日
        // }
        textPaint.setTextSize(textSize);
    }

    private static void drawJkdaFengmian(Canvas canvas,
                                         HealthRecord healthRecord) {
        textPaint.setTextSize(40);
        canvas.drawText(healthRecord.getPersonName(), 663, 609, textPaint);// 个人姓名
        // canvas.drawText(healthRecord.getAddress(), 663, 766,
        // textPaint);//现住地址 这个暂时不填*****
        textPaint.setTextSize(26);
        canvas.drawText(healthRecord.getAddress(), 663, 923, textPaint);// 户籍地址
        textPaint.setTextSize(40);
        canvas.drawText(healthRecord.getMobileNumber(), 663, 1081, textPaint);// 联系电话
        // canvas.drawText(healthRecord.getPersonName(), 831, 1238,
        // textPaint);//街道名称 这个不知道什么。不填****
        // canvas.drawText(healthRecord.getPersonName(), 831, 1238,
        // textPaint);//村委会、居委会名称 不填*******
        // canvas.drawText(healthRecord.getPersonName(), 663, 1552,
        // textPaint);//建档单位 不填********
        // canvas.drawText(healthRecord.getPersonName(), 663, 1630,
        // textPaint);//建档人 不填*******
        // canvas.drawText(healthRecord.get(), 663, 1708, textPaint);//责任医生
        String createTime = healthRecord.getCreateTime();
        if (createTime.length() >= 10) {
            String year = createTime.substring(0, 4);
            String month = createTime.substring(5, 7);
            String day = createTime.substring(8, 10);
            canvas.drawText(year, 663, 1776, textPaint);// 建档日期 年
            canvas.drawText(month, 902, 1776, textPaint);// 建档日期 月
            canvas.drawText(day, 1028, 1776, textPaint);// 建档日期 日
        }
        textPaint.setTextSize(textSize);
    }

    /***
     * 获取疾病史通过对应的编码。
     *
     * @param code
     * @return
     */
    private static String getJibingByCode(String code) {
        String result = "";
        switch (code) {
            // <item text="疾病史">
            // <item key="0201" text="无疾病史" />
            // <item key="0202" text="高血压" />
            // <item key="0203" text="糖尿病" />
            // <item key="0204" text="冠心病" />
            // <item key="0205" text="慢性阻塞性肺疾病" />
            // <item key="0206" text="恶性肿瘤" />
            // <item key="0207" text="脑卒中" />
            // <item key="0208" text="重性精神疾病" />
            // <item key="0209" text="结核病" />
            // <item key="0210" text="肝脏疾病" />
            // <item key="0211" text="先天畸形" />
            // <item key="0212" text="职业病" />
            // <item key="0213" text="肾脏疾病" />
            // <item key="0214" text="贫血" />
            // <item key="0298" text="其他法定传染病" />
            // <item key="0299" text="其他" />
            // </item>
            case "0201":
                result = "1";
                break;
            case "0202":
                result = "2";
                break;
            case "0203":
                result = "3";
                break;
            case "0204":
                result = "4";
                break;
            case "0205":
                result = "5";
                break;
            case "0206":
                result = "6";
                break;
            case "0207":
                result = "7";
                break;
            case "0208":
                result = "8";
                break;
            case "0209":
                result = "9";
                break;
            case "0210":
                result = "10";
                break;
            case "0211":
                // result = "11";
                break;
            case "0212":
                result = "12";
                break;
            case "0213":
                // result = "12";
                break;
            case "0214":
                // result = "12";
                break;
            case "0298":
                result = "11";
                break;
        }
        return result;
    }

    private static String getFuqinByCode(String code) {
        String result = "";
        // <item text="家族疾病史-父亲">
        // <item key="" text="无父亲疾病史" />
        // <item key="0702" text="高血压" />
        // <item key="0703" text="糖尿病" />
        // <item key="0704" text="冠心病" />
        // <item key="0705" text="慢性阻塞性肺疾病" />
        // <item key="0706" text="恶性肿瘤" />
        // <item key="0707" text="脑卒中" />
        // <item key="0708" text="重性精神疾病" />
        // <item key="0709" text="结核病" />
        // <item key="0710" text="肝炎" />
        // <item key="0711" text="先天畸形" />
        // <item key="0799" text="其他" />
        // </item>
        if (code.equals("0701")) {
            result = "1";
        }
        if (code.equals("0702")) {
            result = "2";
        }
        if (code.equals("0703")) {
            result = "3";
        }
        if (code.equals("0704")) {
            result = "4";
        }
        if (code.equals("0705")) {
            result = "5";
        }
        if (code.equals("0706")) {
            result = "6";
        }
        if (code.equals("0707")) {
            result = "7";
        }
        if (code.equals("0708")) {
            result = "8";
        }
        if (code.equals("0709")) {
            result = "9";
        }
        if (code.equals("0710")) {
            result = "10";
        }
        if (code.equals("0711")) {
            result = "11";
        }
        if (code.equals("0799")) {
            result = "12";
        }
        return result;
    }

    private static String getMuqinByCode(String code) {
        String result = "";
        // <item text="家族疾病史-母亲">
        // <item key="0801" text="无母亲疾病史" />
        // <item key="0802" text="高血压" />
        // <item key="0803" text="糖尿病" />
        // <item key="0804" text="冠心病" />
        // <item key="0805" text="慢性阻塞性肺疾病" />
        // <item key="0806" text="恶性肿瘤" />
        // <item key="0807" text="脑卒中" />
        // <item key="0808" text="重性精神疾病" />
        // <item key="0809" text="结核病" />
        // <item key="0810" text="肝炎" />
        // <item key="0811" text="先天畸形" />
        // <item key="0899" text="其他" />
        // </item>
        if (code.equals("0801")) {
            result = "1";
        }
        if (code.equals("0802")) {
            result = "2";
        }
        if (code.equals("0803")) {
            result = "3";
        }
        if (code.equals("0804")) {
            result = "4";
        }
        if (code.equals("0805")) {
            result = "5";
        }
        if (code.equals("0806")) {
            result = "6";
        }
        if (code.equals("0807")) {
            result = "7";
        }
        if (code.equals("0808")) {
            result = "8";
        }
        if (code.equals("0809")) {
            result = "9";
        }
        if (code.equals("0810")) {
            result = "10";
        }
        if (code.equals("0811")) {
            result = "11";
        }
        if (code.equals("0899")) {
            result = "12";
        }
        return result;
    }

    private static String getXiongdiByCode(String code) {
        String result = "";
        // <item text="家族疾病史-兄弟姐妹">
        // <item key="0901" text="无兄弟姐妹疾病史" />
        // <item key="0902" text="高血压" />
        // <item key="0903" text="糖尿病" />
        // <item key="0904" text="冠心病" />
        // <item key="0905" text="慢性阻塞性肺疾病" />
        // <item key="0906" text="恶性肿瘤" />
        // <item key="0907" text="脑卒中" />
        // <item key="0908" text="重性精神疾病" />
        // <item key="0909" text="结核病" />
        // <item key="0910" text="肝炎" />
        // <item key="0911" text="先天畸形" />
        // <item key="0999" text="其他" />
        // </item>
        if (code.equals("0901")) {
            result = "1";
        }
        if (code.equals("0902")) {
            result = "2";
        }
        if (code.equals("0903")) {
            result = "3";
        }
        if (code.equals("0904")) {
            result = "4";
        }
        if (code.equals("0905")) {
            result = "5";
        }
        if (code.equals("0906")) {
            result = "6";
        }
        if (code.equals("0907")) {
            result = "7";
        }
        if (code.equals("0908")) {
            result = "8";
        }
        if (code.equals("0909")) {
            result = "9";
        }
        if (code.equals("0910")) {
            result = "10";
        }
        if (code.equals("0911")) {
            result = "11";
        }
        if (code.equals("0999")) {
            result = "12";
        }
        return result;
    }

    private static String getZinvByCode(String code) {
        String result = "";
        // <item text="家族疾病史-子女">
        // <item key="1001" text="无子女疾病史" />
        // <item key="1002" text="高血压" />
        // <item key="1003" text="糖尿病" />
        // <item key="1004" text="冠心病" />
        // <item key="1005" text="慢性阻塞性肺疾病" />
        // <item key="1006" text="恶性肿瘤" />
        // <item key="1007" text="脑卒中" />
        // <item key="1008" text="重性精神疾病" />
        // <item key="1009" text="结核病" />
        // <item key="1010" text="肝炎" />
        // <item key="1011" text="先天畸形" />
        // <item key="1099" text="其他" />
        // </item>
        if (code.equals("1001")) {
            result = "1";
        }
        if (code.equals("1002")) {
            result = "2";
        }
        if (code.equals("1003")) {
            result = "3";
        }
        if (code.equals("1004")) {
            result = "4";
        }
        if (code.equals("1005")) {
            result = "5";
        }
        if (code.equals("1006")) {
            result = "6";
        }
        if (code.equals("1007")) {
            result = "7";
        }
        if (code.equals("1008")) {
            result = "8";
        }
        if (code.equals("1009")) {
            result = "9";
        }
        if (code.equals("1010")) {
            result = "10";
        }
        if (code.equals("1011")) {
            result = "11";
        }
        if (code.equals("1099")) {
            result = "12";
        }
        return result;
    }

    public static void createGXYBitmap(Context context, List<Visit_info> lists) {
        System.gc();
        // 体检表1的画布，用来画好字。然后保存。
        Bitmap gxyBitmap = getBitmapByResId(context, R.raw.gxy);
        Bitmap gxy = Bitmap.createBitmap(gxyBitmap.getWidth(),
                gxyBitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(gxy);
        canvas.drawBitmap(gxyBitmap, 0, 0, null);
        gxyBitmap.recycle();
        int jiangeX = 288;
        if (lists != null) {
            if (lists.size() > 0) {
                for (int j = 0; j < lists.size(); j++) {
                    Visit_info visit_info = lists.get(j);
                    if (j == 0) {
                        canvas.drawText(BaseActivity.getName(), 361 + j
                                * jiangeX, 224, textPaint);// 个人姓名
                    }
                    String date = visit_info.getVisitDate();
                    String year = date.substring(0, 4);
                    String month = date.substring(5, 7);
                    String day = date.substring(8, 10);
                    canvas.drawText(year, 390 + j * jiangeX, 265, textPaint);
                    canvas.drawText(month, 506 + j * jiangeX, 265, textPaint);
                    canvas.drawText(day, 569 + j * jiangeX, 265, textPaint);
                    canvas.drawText(visit_info.getVisitType(), 617 + j// 随访方式
                            * jiangeX, 299, smallTextPaint);
                    // 目前症状。
                    String zhengzhuangstr = visit_info.getCurrentSymptoms();
                    if (zhengzhuangstr != null && zhengzhuangstr.length() > 0) {
                        int jiangexx = 30;
                        String[] ss = zhengzhuangstr.split(",");
                        for (int i = 0; i < ss.length; i++) {
                            switch (ss[i]) {
                                case "9":
                                    ss[i] = "1";
                                    break;
                                case "1":
                                    ss[i] = "2";
                                    break;
                                case "2":
                                    ss[i] = "3";
                                    break;
                                case "3":
                                    ss[i] = "4";
                                    break;
                                case "4":
                                    ss[i] = "5";
                                    break;
                                case "5":
                                    ss[i] = "6";
                                    break;
                                case "6":
                                    ss[i] = "7";
                                    break;
                                case "7":
                                    ss[i] = "8";
                                    break;
                                case "8":
                                    ss[i] = "9";
                                    break;
                                case "10":
                                    ss[i] = "";
                                    break;
                                default:
                                    ss[i] = "";
                                    break;
                            }
                            canvas.drawText(ss[i], 396 + i * jiangexx + j
                                    * jiangeX, 346, smallTextPaint);
                        }
                        canvas.drawText(visit_info.getOtherSymptoms(), 391 + j
                                * jiangeX, 434, textPaint);
                    }
                    canvas.drawText(visit_info.getConstriction() + "/"
                                    + visit_info.getDiastolic(), 408 + j * jiangeX,
                            646, textPaint);// 血压
                    canvas.drawText(visit_info.getWeight(), 405 + j * jiangeX,
                            691, textPaint);// 体重
                    canvas.drawText(visit_info.getTargetWeight(), 528 + j
                            * jiangeX, 691, textPaint);// 目标体重
                    canvas.drawText(visit_info.getBmi(), 405 + j * jiangeX,
                            738, textPaint);// 体质指数
                    canvas.drawText(visit_info.getHeartRate(), 405 + j
                            * jiangeX, 783, textPaint);// 心率
                    canvas.drawText(visit_info.getTargetHeartRate(), 528 + j
                            * jiangeX, 783, textPaint);// 心率目标
                    canvas.drawText(visit_info.getOtherSigns(), 405 + j
                            * jiangeX, 831, textPaint);// 其他
                    canvas.drawText(visit_info.getSmokeCount(), 405 + j
                            * jiangeX, 877, textPaint);// 抽烟
                    canvas.drawText(visit_info.getTargetSmokeCount(), 528 + j
                            * jiangeX, 877, textPaint);// 抽烟目标
                    canvas.drawText(visit_info.getDrinkCount(), 405 + j
                            * jiangeX, 922, textPaint);// 喝酒
                    canvas.drawText(visit_info.getTargetDrinkCount(), 528 + j
                            * jiangeX, 922, textPaint);// 喝酒目标
                    canvas.drawText(visit_info.getTrainTimesWeek(), 412 + j
                            * jiangeX, 974, textPaint);// 运动次数
                    canvas.drawText(visit_info.getTrainMinute(), 513 + j
                            * jiangeX, 974, textPaint);// 运动时间（分）
                    canvas.drawText(visit_info.getTargetTrainTimesWeek(), 412
                            + j * jiangeX, 1003, textPaint);// 运动次数目标
                    canvas.drawText(visit_info.getTargetTrainMinute(), 513 + j
                            * jiangeX, 1003, textPaint);// 运动时间（分）
                    String yan = visit_info.getSalt();
                    if ("1".equals(yan)) {
                        yan = "轻";
                    } else if ("2".equals(yan)) {
                        yan = "中";
                    } else if ("3".equals(yan)) {
                        yan = "重";
                    }
                    String targetyan = visit_info.getTargetSalt();
                    if ("1".equals(targetyan)) {
                        targetyan = "轻";
                    } else if ("2".equals(targetyan)) {
                        targetyan = "中";
                    } else if ("3".equals(targetyan)) {
                        targetyan = "重";
                    }
                    if (j == 2) {
                        canvas.drawText(visit_info.getPsychologyChange(), 1185,
                                1111, smallTextPaint);// 心理调整
                        canvas.drawText(visit_info.getObeyDoctor(), 1185, 1156,
                                smallTextPaint);// 遵医行为
                    } else if (j == 3) {
                        canvas.drawText(visit_info.getPsychologyChange(), 1470,
                                1111, smallTextPaint);// 心理调整
                        canvas.drawText(visit_info.getObeyDoctor(), 1470, 1156,
                                smallTextPaint);// 遵医行为
                    } else {
                        canvas.drawText(visit_info.getPsychologyChange(), 633
                                + j * jiangeX, 1111, smallTextPaint);// 心理调整
                        canvas.drawText(visit_info.getObeyDoctor(), 633 + j
                                * jiangeX, 1156, smallTextPaint);// 遵医行为
                    }
                    canvas.drawText(yan, 407 + j * jiangeX, 1058,
                            smallTextPaint);// 摄盐
                    canvas.drawText(targetyan, 524 + j * jiangeX, 1058,
                            smallTextPaint);// 摄盐目标
                    canvas.drawText(visit_info.getAuxiliaryCheck(), 389 + j
                            * jiangeX, 1227, textPaint);// 辅助检查
                    canvas.drawText(visit_info.getMedicine(),
                            605 + j * jiangeX, 1282, smallTextPaint);// 服药依从性
                    if (j == 3) {
                        canvas.drawText(visit_info.getMedicineBadEffect(),
                                1482, 1327, smallTextPaint);// 药物不良反应
                    } else {
                        canvas.drawText(visit_info.getMedicineBadEffect(), 630
                                + j * jiangeX, 1327, smallTextPaint);// 药物不良反应
                    }
                    canvas.drawText(visit_info.getVisitEvaluate(), 605 + j
                            * jiangeX, 1397, smallTextPaint);// 随访分类
                    String xml = visit_info.getXml();
                    List<MedicineDesc> mds = XmlTool
                            .parseMedicineDescByxml(xml);
                    // List<MedicineDesc> mds = visit_info.getMedicineDescs();
                    int jiangeY = 94;
                    if (mds != null && mds.size() > 0) {
                        MedicineDesc md = null;
                        float textsize = textPaint.getTextSize();
                        textPaint.setTextSize(textsize - 3);
                        for (int i = 0; i < mds.size(); i++) {
                            md = mds.get(i);
                            // <otherMedicineDesc>药物名称</otherMedicineDesc>
                            // <medicineFrequency>次数</medicineFrequency>
                            // <days>天数</days>
                            // <medicineDosage>每次剂量</medicineDosage>
                            // <medicineUnit>剂量单位</medicineUnit>
                            canvas.drawText(md.getOtherMedicineDesc(), 382 + j
                                    * jiangeX, 1442 + i * jiangeY, textPaint);// 药物名
                            canvas.drawText(md.getMedicineFrequency(), 444 + j
                                    * jiangeX, 1485 + i * jiangeY, textPaint);// 次数
                            canvas.drawText(md.getMedicineDosage(), 580 + j
                                    * jiangeX, 1485 + i * jiangeY, textPaint);// 剂量
                        }
                        textPaint.setTextSize(textsize);
                    }
                    canvas.drawText(visit_info.getNoVisitReason(), 389 + j
                            * jiangeX, 1816, textPaint);// 原因
                    // canvas.drawText(visit_info.getNoVisitReason(), 389, 1866,
                    // textPaint);// 机构及科别
                    canvas.drawText(visit_info.getNextDate(),
                            389 + j * jiangeX, 1915, textPaint);// 下次随访日期
                    // canvas.drawText(visit_info.getNoVisitReason(), 389, 1975,
                    // textPaint);// 随访医生签名
                }
            }
        }
        // Intent intent = new Intent();
        // intent.setAction("android.intent.action.View");
        // FileSaveUtil.saveBitmap(gxy, FileSaveUtil.getSDCardPath() + "/"
        // + BaseActivity.getName(), "gxy.png");
        // File file = new File(FileSaveUtil.getSDCardPath() + "/"
        // + BaseActivity.getName(), "gxy.png");
        // intent.setDataAndType(Uri.fromFile(file), "image/*");
        // context.startActivity(intent);
        FileSaveUtil.saveBitmap(gxy, FileSaveUtil.getSDCardPath() + "/"
                + BaseActivity.getName(), "gxy.png");
        gxy.recycle();
        Intent intent = new Intent();
        intent.setAction("android.intent.action.SEND_MULTIPLE");
        // intent.setDataAndType(Uri.fromFile(file), "image/*");
        intent.setType("image/*");
        ArrayList<Uri> imageUris = new ArrayList<Uri>();
        File file = new File(FileSaveUtil.getSDCardPath() + "/"
                + BaseActivity.getName(), "gxy.png");
        imageUris.add(Uri.fromFile(file));
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
        context.startActivity(intent);
    }

    public static void createTNBBitmap(Context context, List<Visit_info2> lists) {
        System.gc();
        // 体检表1的画布，用来画好字。然后保存。
        Bitmap tnbBitmap = getBitmapByResId(context, R.raw.tnb);
        Bitmap tnb = Bitmap.createBitmap(tnbBitmap.getWidth(),
                tnbBitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(tnb);
        canvas.drawBitmap(tnbBitmap, 0, 0, null);
        tnbBitmap.recycle();
        int jiangeX = 300;
        if (lists != null && lists.size() > 0) {
            for (int j = 0; j < lists.size(); j++) {
                Visit_info2 uploadBean = lists.get(j);
                // 389 267
                canvas.drawText(uploadBean.getVisitDate(), 389 + j * jiangeX,
                        267, textPaint);// 随访日期
                canvas.drawText(uploadBean.getVisitWay(), 634 + j * jiangeX,
                        302, smallTextPaint);// 随访类型
                // 目前症状。
                String zhengzhuangstr = uploadBean.getSymptoms();
                if (zhengzhuangstr != null && zhengzhuangstr.length() > 0) {
                    String[] ss = zhengzhuangstr.split(",");
                    for (int i = 0; i < ss.length; i++) {
                        switch (ss[i]) {
                            case "9":
                                ss[i] = "1";
                                break;
                            case "1":
                                ss[i] = "2";
                                break;
                            case "2":
                                ss[i] = "3";
                                break;
                            case "3":
                                ss[i] = "4";
                                break;
                            case "4":
                                ss[i] = "5";
                                break;
                            case "5":
                                ss[i] = "6";
                                break;
                            case "6":
                                ss[i] = "7";
                                break;
                            case "7":
                                ss[i] = "8";
                                break;
                            case "8":
                                ss[i] = "9";
                                break;
                            case "10":
                                ss[i] = "";
                                break;
                        }
                        canvas.drawText(ss[i], 395 + i * jiangeX, 341,
                                smallTextPaint);
                    }
                    canvas.drawText(uploadBean.getOtherSymptoms(), 393 + j
                            * jiangeX, 417, textPaint);
                }
                canvas.drawText(
                        uploadBean.getConstriction() + "/"
                                + uploadBean.getDiastolic(), 394 + j * jiangeX,
                        575, textPaint);// 血压
                canvas.drawText(uploadBean.getWeight(), 394 + j * jiangeX, 618,
                        textPaint);// 体重
                canvas.drawText(uploadBean.getTargetWeight(),
                        553 + j * jiangeX, 618, textPaint);// 目标体重
                canvas.drawText(uploadBean.getBmi(), 394 + j * jiangeX, 658,
                        textPaint);// 体质指数
                canvas.drawText(uploadBean.getPulsation(), 635 + j * jiangeX,
                        693, smallTextPaint);// 足背
                canvas.drawText(uploadBean.getOtherSigns(), 635 + j * jiangeX,
                        739, textPaint);// 其他
                canvas.drawText(uploadBean.getSmokeCount(), 391 + j * jiangeX,
                        776, textPaint);// 抽烟
                canvas.drawText(uploadBean.getTargetSmokeCount(), 473 + j
                        * jiangeX, 776, textPaint);// 抽烟目标
                canvas.drawText(uploadBean.getDrinkCount(), 391 + j * jiangeX,
                        812, textPaint);// 喝酒
                canvas.drawText(uploadBean.getTargetDrinkCount(), 473 + j
                        * jiangeX, 812, textPaint);// 喝酒目标
                canvas.drawText(uploadBean.getTrainTimesWeek(), 390 + j
                        * jiangeX, 849, textPaint);// 运动次数
                canvas.drawText(uploadBean.getTrainMinute(), 500 + j * jiangeX,
                        849, textPaint);// 运动时间（分）
                canvas.drawText(uploadBean.getTargetTrainTimesWeek(), 390 + j
                        * jiangeX, 883, textPaint);// 运动次数目标
                canvas.drawText(uploadBean.getTargetTrainMinute(), 500 + j
                        * jiangeX, 883, textPaint);// 运动时间（分）
                canvas.drawText(uploadBean.getFood(), 395 + j * jiangeX, 924,
                        textPaint);// 主食
                canvas.drawText(uploadBean.getTargetFood(), 552 + j * jiangeX,
                        924, textPaint);// 主食目标
                if (j == 0) {
                    canvas.drawText(uploadBean.getPsychologyChange(), 622 + j
                            * jiangeX, 960, smallTextPaint);// 心理调整
                } else if (j == 1) {
                    canvas.drawText(uploadBean.getPsychologyChange(), 910, 960,
                            smallTextPaint);// 心理调整
                } else if (j == 2) {
                    canvas.drawText(uploadBean.getPsychologyChange(), 1209,
                            960, smallTextPaint);// 心理调整
                } else if (j == 3) {
                    canvas.drawText(uploadBean.getPsychologyChange(), 1523,
                            960, smallTextPaint);// 心理调整
                }
                if (j == 0) {
                    canvas.drawText(uploadBean.getObeyDoctor(), 622 + j
                            * jiangeX, 1000, smallTextPaint);// 遵医行为
                } else if (j == 1) {
                    canvas.drawText(uploadBean.getObeyDoctor(), 910, 1000,
                            smallTextPaint);// 遵医行为
                } else if (j == 2) {
                    canvas.drawText(uploadBean.getObeyDoctor(), 1209, 1000,
                            smallTextPaint);// 遵医行为
                } else if (j == 3) {
                    canvas.drawText(uploadBean.getObeyDoctor(), 1523, 1000,
                            smallTextPaint);// 遵医行为
                }
                System.out.println("遵医行为：" + uploadBean.getObeyDoctor());
                canvas.drawText(uploadBean.getFbs(), 412 + j * jiangeX, 1046,
                        textPaint);// 空腹血糖
                String date = uploadBean.getTestDate();
                if (date.length() > 7) {
                    String month = date.substring(5, 7);
                    String day = date.substring(8, 10);
                    canvas.drawText(month, 516 + j * jiangeX, 1118, textPaint);// 月
                    canvas.drawText(day, 595 + j * jiangeX, 1118, textPaint);// 日
                }
                canvas.drawText(uploadBean.getMedicine(), 610 + j * jiangeX,
                        1272, smallTextPaint);// 服药依从性
                canvas.drawText(uploadBean.getAdverseReactions(), 634 + j
                        * jiangeX, 1319, smallTextPaint);// 药物不良反应
                if (j == 0) {
                    canvas.drawText(uploadBean.getGlycopenia(), 635 + j
                            * jiangeX, 1363, smallTextPaint);// 低血糖反应
                } else if (j == 1) {
                    canvas.drawText(uploadBean.getGlycopenia(), 922, 1363,
                            smallTextPaint);// 低血糖反应
                } else if (j == 2) {
                    canvas.drawText(uploadBean.getGlycopenia(), 1224, 1363,
                            smallTextPaint);// 低血糖反应
                } else if (j == 3) {
                    canvas.drawText(uploadBean.getGlycopenia(), 1536, 1363,
                            smallTextPaint);// 低血糖反应
                }
                canvas.drawText(uploadBean.getVisitType(), 396 + j * jiangeX,
                        1484, smallTextPaint);// 此次随访分类
                // 药物
                String xml = uploadBean.getXml();
                List<MedicineDesc> mds = XmlTool.parseMedicineDescByxml(xml);
                // List<MedicineDesc> mds = uploadBean.getMedicineDescs();
                if (mds != null && mds.size() > 0) {
                    MedicineDesc md = null;
                    int jiangeY = 80;
                    for (int i = 0; i < mds.size(); i++) {
                        md = mds.get(i);
                        // <otherMedicineDesc>药物名称</otherMedicineDesc>
                        // <medicineFrequency>次数</medicineFrequency>
                        // <days>天数</days>
                        // <medicineDosage>每次剂量</medicineDosage>
                        // <medicineUnit>剂量单位</medicineUnit>
                        canvas.drawText(md.getOtherMedicineDesc(), 397 + j
                                * jiangeX, 1530 + i * jiangeY, textPaint);// 药物名
                        canvas.drawText(md.getMedicineFrequency(), 443 + j
                                * jiangeX, 1572 + i * jiangeY, textPaint);// 次数
                        canvas.drawText(md.getMedicineDosage(), 591 + j
                                * jiangeX, 1572 + i * jiangeY, textPaint);// 剂量
                    }
                }
                canvas.drawText(uploadBean.getReferralReason(), 391 + j
                        * jiangeX, 1904, textPaint);// 原因
                canvas.drawText(uploadBean.getReferralOffice(), 391 + j
                        * jiangeX, 1944, textPaint);// 科室
                canvas.drawText(uploadBean.getNextDate(), 391 + j * jiangeX,
                        1987, textPaint);// 下次随访日期
                // canvas.drawText(uploadBean.getVisitType(), 391 + j
                // * jiangeX, 2027, textPaint);//

            }
            FileSaveUtil.saveBitmap(tnb, FileSaveUtil.getSDCardPath() + "/"
                    + BaseActivity.getName(), "tnb.png");
            tnb.recycle();
            Intent intent = new Intent();
            intent.setAction("android.intent.action.SEND_MULTIPLE");
            // intent.setDataAndType(Uri.fromFile(file), "image/*");
            intent.setType("image/*");
            ArrayList<Uri> imageUris = new ArrayList<Uri>();
            File file = new File(FileSaveUtil.getSDCardPath() + "/"
                    + BaseActivity.getName(), "tnb.png");
            imageUris.add(Uri.fromFile(file));
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
            context.startActivity(intent);
        }
    }
}
